Goby3 3.5.1
2026.06.04
Loading...
Searching...
No Matches
goby::middleware::SimpleThread< Config, ImplementationTag > Class Template Reference

Implements Thread for a three layer middleware setup ([ intervehicle [ interprocess [ interthread ] ] ]) based around InterVehicleForwarder. More...

#include <goby/middleware/application/simple_thread.h>

Inheritance diagram for goby::middleware::SimpleThread< Config, ImplementationTag >:
goby::middleware::Thread< Config, InterVehicleForwarder< InterProcessForwarder< InterThreadTransporter, void > > > goby::middleware::coroner::Thread< SimpleThread< Config, void > >

Public Member Functions

 SimpleThread (const Config &cfg, double loop_freq_hertz=0, int index=-1)
 Construct a thread with a given configuration, optionally a loop frequency and/or index.
 SimpleThread (const Config &cfg, boost::units::quantity< boost::units::si::frequency > loop_freq, int index=-1)
 Construct a thread with a given configuration, a loop frequency (using boost::units) and optionally an index.
InterVehicleForwarder< InterProcessForwarder< InterThreadTransporter, ImplementationTag > > & intervehicle ()
 Access the transporter on the intervehicle layer (which wraps interprocess and interthread).
InterProcessForwarder< InterThreadTransporter, ImplementationTag > & interprocess ()
 Access the transporter on the interprocess layer (which wraps interthread).
InterThreadTransporterinterthread ()
 Access the transporter on the interthread layer (this is the innermost transporter).
Public Member Functions inherited from goby::middleware::Thread< Config, InterVehicleForwarder< InterProcessForwarder< InterThreadTransporter, void > > >
 Thread (const Config &cfg, InterVehicleForwarder< InterProcessForwarder< InterThreadTransporter, void > > *transporter, int index)
 Construct a thread with a given configuration, underlying transporter, and index (for multiple instantiations), but without any loop() frequency.
virtual ~Thread ()
void run (std::atomic< bool > &alive)
 Run the thread until the boolean reference passed is set false. This call blocks, and should be run in a std::thread by the caller.
int index () const
std::type_index type_index ()
void set_type_index (std::type_index type_i)
std::string name ()
void set_name (const std::string &name)
int uid ()
void set_uid (int uid)
double loop_frequency_hertz () const
decltype(loop_frequency_) loop_frequency () const
void set_loop_frequency_hertz (double loop_freq_hertz)
void set_loop_frequency (boost::units::quantity< boost::units::si::frequency > loop_freq)

Friends

class coroner::Thread< SimpleThread< Config, ImplementationTag > >

Additional Inherited Members

Public Types inherited from goby::middleware::Thread< Config, InterVehicleForwarder< InterProcessForwarder< InterThreadTransporter, void > > >
using Transporter
Static Public Attributes inherited from goby::middleware::Thread< Config, InterVehicleForwarder< InterProcessForwarder< InterThreadTransporter, void > > >
static constexpr goby::middleware::Group shutdown_group_
static constexpr goby::middleware::Group joinable_group_
Protected Member Functions inherited from goby::middleware::Thread< Config, InterVehicleForwarder< InterProcessForwarder< InterThreadTransporter, void > > >
void set_transporter (InterVehicleForwarder< InterProcessForwarder< InterThreadTransporter, void > > *transporter)
virtual void loop ()
double loop_max_frequency () const
void run_once ()
InterVehicleForwarder< InterProcessForwarder< InterThreadTransporter, void > > & transporter () const
const Config & cfg () const
virtual void initialize ()
virtual void finalize ()
void thread_health (goby::middleware::protobuf::ThreadHealth &health)
virtual void health (goby::middleware::protobuf::ThreadHealth &health)
 Called when HealthRequest is made by goby_coroner.
void thread_quit ()
bool alive ()
Protected Member Functions inherited from goby::middleware::coroner::Thread< SimpleThread< Config, void > >
void subscribe_coroner ()

Detailed Description

template<typename Config, typename ImplementationTag = void>
class goby::middleware::SimpleThread< Config, ImplementationTag >

Implements Thread for a three layer middleware setup ([ intervehicle [ interprocess [ interthread ] ] ]) based around InterVehicleForwarder.

Template Parameters
ConfigConfiguration type
ImplementationTagTag type selecting the interprocess implementation (e.g. zeromq::detail::InterProcessTag). Defaults to void (deprecated; use zeromq::SimpleThread or udpm::SimpleThread instead).

Derive from this class to create standalone threads that can be launched and joined by MultiThreadApplication's launch_thread and join_thread methods.

Definition at line 45 of file simple_thread.h.

Constructor & Destructor Documentation

◆ SimpleThread() [1/2]

template<typename Config, typename ImplementationTag = void>
goby::middleware::SimpleThread< Config, ImplementationTag >::SimpleThread ( const Config & cfg,
double loop_freq_hertz = 0,
int index = -1 )
inline

Construct a thread with a given configuration, optionally a loop frequency and/or index.

Parameters
cfgData to configure the code running in this thread
loop_freq_hertzThe frequency at which to attempt to call loop(), assuming the thread isn't blocked handling transporter callbacks (e.g. subscribe callbacks). Zero or negative indicates loop() will never be called.
indexNumeric index to identify this instantiation of the SimpleThread (only necessary if multiple Threads of the same type are created)

Definition at line 62 of file simple_thread.h.

◆ SimpleThread() [2/2]

template<typename Config, typename ImplementationTag = void>
goby::middleware::SimpleThread< Config, ImplementationTag >::SimpleThread ( const Config & cfg,
boost::units::quantity< boost::units::si::frequency > loop_freq,
int index = -1 )
inline

Construct a thread with a given configuration, a loop frequency (using boost::units) and optionally an index.

Parameters
cfgData to configure the code running in this thread
loop_freqThe frequency at which to attempt to call loop(), assuming the thread isn't blocked handling transporter callbacks (e.g. subscribe callbacks). Zero or negative indicates loop() will never be called.
indexNumeric index to identify this instantiation of the SimpleThread (only necessary if multiple Threads of the same type are created)

Definition at line 72 of file simple_thread.h.

Member Function Documentation

◆ interprocess()

template<typename Config, typename ImplementationTag = void>
InterProcessForwarder< InterThreadTransporter, ImplementationTag > & goby::middleware::SimpleThread< Config, ImplementationTag >::interprocess ( )
inline

Access the transporter on the interprocess layer (which wraps interthread).

Definition at line 96 of file simple_thread.h.

◆ interthread()

template<typename Config, typename ImplementationTag = void>
InterThreadTransporter & goby::middleware::SimpleThread< Config, ImplementationTag >::interthread ( )
inline

Access the transporter on the interthread layer (this is the innermost transporter).

Definition at line 102 of file simple_thread.h.

◆ intervehicle()

template<typename Config, typename ImplementationTag = void>
InterVehicleForwarder< InterProcessForwarder< InterThreadTransporter, ImplementationTag > > & goby::middleware::SimpleThread< Config, ImplementationTag >::intervehicle ( )
inline

Access the transporter on the intervehicle layer (which wraps interprocess and interthread).

Definition at line 90 of file simple_thread.h.

◆ coroner::Thread< SimpleThread< Config, ImplementationTag > >

template<typename Config, typename ImplementationTag = void>
friend class coroner::Thread< SimpleThread< Config, ImplementationTag > >
friend

Definition at line 1 of file simple_thread.h.


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