mavtables
0.2.1
MAVLink router and firewall.
|
#include <InterfaceThreader.hpp>
Public Types | |
enum | Threads { START, DELAY_START } |
Public Member Functions | |
InterfaceThreader (std::unique_ptr< Interface > interface, std::chrono::microseconds=std::chrono::microseconds(100000), Threads start_threads=InterfaceThreader::START) | |
InterfaceThreader (const InterfaceThreader &other)=delete | |
InterfaceThreader (InterfaceThreader &&other)=delete | |
~InterfaceThreader () | |
void | start () |
void | shutdown () |
InterfaceThreader & | operator= (const InterfaceThreader &other)=delete |
InterfaceThreader & | operator= (InterfaceThreader &&other)=delete |
A multithreaded interface runner.
This class runs a given interface. It does this by calling the Interface's Interface::send_packet and Interface::receive_packet methods repeatedly until the runner is shutdown. This is a threaded runner and thus it runs these methods in two separate threads which are managed by the InterfaceThreader class.
Call the shutdown method to stop running the interface and cleanup the threads.
Definition at line 42 of file InterfaceThreader.hpp.
Enumerator | |
---|---|
START | Start the interface (and worker threads) immediately. |
DELAY_START | Delay starting, use start to launch threads. |
Definition at line 45 of file InterfaceThreader.hpp.
InterfaceThreader::InterfaceThreader | ( | std::unique_ptr< Interface > | interface, |
std::chrono::microseconds | timeout = std::chrono::microseconds(100000) , |
||
Threads | start_threads = InterfaceThreader::START |
||
) |
Construct and optionally start an interface threader.
interface | The Interface to run in TX/RX threads. It's Interface::send_packet and Interface::receive_packet methods will be called repeatedly in two separate worker threads. |
timeout | The maximum amount of time to wait for incoming data or a packet to transmit. The default value is 100000 us (100 ms). |
start_threads | Set to InterfaceThreader::START (the default value) to start the interface (including worker threads) on construction. Set to InterfaceThreader::DELAY_START to delay starting the interface (and worker threads) until the start method is called. |
Definition at line 80 of file InterfaceThreader.cpp.
References START, and start().
|
delete |
|
delete |
InterfaceThreader::~InterfaceThreader | ( | ) |
Shutdown the interface and its associated worker threads.
Definition at line 97 of file InterfaceThreader.cpp.
References shutdown().
|
delete |
|
delete |
void InterfaceThreader::shutdown | ( | ) |
Shutdown the interface and its associated worker threads.
Definition at line 119 of file InterfaceThreader.cpp.
void InterfaceThreader::start | ( | ) |
Start the worker threads for the interface.
This starts the receiver and transmitter threads.
Definition at line 107 of file InterfaceThreader.cpp.