mavtables  0.2.1
MAVLink router and firewall.
Public Types | Public Member Functions | List of all members
InterfaceThreader Class Reference

#include <InterfaceThreader.hpp>

Collaboration diagram for InterfaceThreader:
Collaboration graph

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 ()
 
InterfaceThreaderoperator= (const InterfaceThreader &other)=delete
 
InterfaceThreaderoperator= (InterfaceThreader &&other)=delete
 

Detailed Description

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.

Note
This is the only place where threading occurs in mavtables.

Definition at line 42 of file InterfaceThreader.hpp.

Member Enumeration Documentation

◆ Threads

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.

Constructor & Destructor Documentation

◆ InterfaceThreader() [1/3]

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.

Parameters
interfaceThe 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.
timeoutThe maximum amount of time to wait for incoming data or a packet to transmit. The default value is 100000 us (100 ms).
start_threadsSet 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().

Here is the call graph for this function:

◆ InterfaceThreader() [2/3]

InterfaceThreader::InterfaceThreader ( const InterfaceThreader other)
delete

◆ InterfaceThreader() [3/3]

InterfaceThreader::InterfaceThreader ( InterfaceThreader &&  other)
delete

◆ ~InterfaceThreader()

InterfaceThreader::~InterfaceThreader ( )

Shutdown the interface and its associated worker threads.

Definition at line 97 of file InterfaceThreader.cpp.

References shutdown().

Here is the call graph for this function:

Member Function Documentation

◆ operator=() [1/2]

InterfaceThreader& InterfaceThreader::operator= ( const InterfaceThreader other)
delete

◆ operator=() [2/2]

InterfaceThreader& InterfaceThreader::operator= ( InterfaceThreader &&  other)
delete

◆ shutdown()

void InterfaceThreader::shutdown ( )

Shutdown the interface and its associated worker threads.

Note
This will always be called by the interface's destructor.

Definition at line 119 of file InterfaceThreader.cpp.

Here is the caller graph for this function:

◆ start()

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.

Here is the caller graph for this function:

The documentation for this class was generated from the following files: