Goby3  3.1.5a
2024.05.23
goby::middleware::MultiThreadTest< Config > Class Template Reference

Base class for building multithreaded Goby tests that do not have perform any interprocess (or outer) communications, but only communicate internally via the InterThreadTransporter. The only difference with this class and MultiThreadStandaloneApplication is that the interprocess() and intervehicle() methods are implemented here (as dummy calls to interthread()) to allow this to be a drop-in replacement for testing interthread comms on existing MultiThreadApplication subclasses. More...

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

Inheritance diagram for goby::middleware::MultiThreadTest< Config >:
goby::middleware::MultiThreadStandaloneApplication< Config > goby::middleware::MultiThreadApplicationBase< Config, InterThreadTransporter > goby::middleware::Application< Config > goby::middleware::Thread< Config, InterThreadTransporter >

Public Member Functions

 MultiThreadTest (boost::units::quantity< boost::units::si::frequency > loop_freq=0 *boost::units::si::hertz)
 Construct the test running at the given frequency. More...
 
virtual ~MultiThreadTest ()
 
- Public Member Functions inherited from goby::middleware::MultiThreadStandaloneApplication< Config >
 MultiThreadStandaloneApplication (double loop_freq_hertz=0)
 Construct the application calling loop() at the given frequency (double overload) More...
 
 MultiThreadStandaloneApplication (boost::units::quantity< boost::units::si::frequency > loop_freq)
 Construct the application calling loop() at the given frequency (boost::units overload) More...
 
virtual ~MultiThreadStandaloneApplication ()
 
- Public Member Functions inherited from goby::middleware::MultiThreadApplicationBase< Config, InterThreadTransporter >
void launch_thread ()
 
void launch_thread (int index)
 
void launch_thread (const ThreadConfig &cfg)
 
void launch_thread (int index, const ThreadConfig &cfg)
 
void launch_thread_without_cfg ()
 
void launch_thread_without_cfg (int index)
 
void join_thread (int index=-1)
 
void launch_timer (boost::units::quantity< boost::units::si::frequency > freq, std::function< void()> on_expire)
 
void join_timer ()
 
int running_thread_count ()
 
- Public Member Functions inherited from goby::middleware::Application< Config >
 Application ()
 
virtual ~Application ()
 
- Public Member Functions inherited from goby::middleware::Thread< Config, InterThreadTransporter >
 Thread (const Config &cfg, InterThreadTransporter *transporter, int index)
 Construct a thread with a given configuration, underlying transporter, and index (for multiple instantiations), but without any loop() frequency. More...
 
 Thread (const Config &cfg, InterThreadTransporter *transporter, double loop_freq_hertz=0, int index=-1)
 Construct a thread with all possible metadata (using double to specify frequency in Hertz) More...
 
 Thread (const Config &cfg, InterThreadTransporter *transporter, boost::units::quantity< boost::units::si::frequency > loop_freq, int index=-1)
 Construct a thread with all possible metadata (using boost::units to specify frequency) More...
 
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. More...
 
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)
 

Protected Member Functions

InterThreadTransporterinterprocess ()
 
InterThreadTransporterintervehicle ()
 
- Protected Member Functions inherited from goby::middleware::MultiThreadApplicationBase< Config, InterThreadTransporter >
 MultiThreadApplicationBase (boost::units::quantity< boost::units::si::frequency > loop_freq, InterThreadTransporter *transporter)
 
virtual ~MultiThreadApplicationBase ()
 
InterThreadTransporterinterthread ()
 
virtual void post_finalize () override
 Called just after finalize. More...
 
std::map< std::type_index, std::map< int, ThreadManagement > > & threads ()
 
void join_all_threads ()
 
- Protected Member Functions inherited from goby::middleware::Application< Config >
virtual void pre_initialize ()
 Called just before initialize. More...
 
virtual void initialize ()
 Perform any initialize tasks that couldn't be done in the constructor. More...
 
virtual void post_initialize ()
 Called just after initialize. More...
 
virtual void pre_finalize ()
 Called just before finalize. More...
 
virtual void finalize ()
 Perform any final cleanup actions just before the destructor is called. More...
 
void quit (int return_value=0)
 Requests a clean exit. More...
 
const Config & app_cfg ()
 Accesses configuration object passed at launch. More...
 
const util::UTMGeodesygeodesy ()
 Accesses the geodetic conversion tool if lat_origin and lon_origin were provided. More...
 
bool has_geodesy ()
 Returns if the geodesy tool is configured with a datum. More...
 
std::string app_name ()
 
void configure_geodesy (goby::util::UTMGeodesy::LatLonPoint datum)
 
- Protected Member Functions inherited from goby::middleware::Thread< Config, InterThreadTransporter >
 Thread (const Config &cfg, boost::units::quantity< boost::units::si::frequency > loop_freq, int index=-1)
 
void set_transporter (InterThreadTransporter *transporter)
 
virtual void loop ()
 
double loop_frequency_hertz () const
 
decltype(loop_frequency_) loop_frequency () const
 
double loop_max_frequency () const
 
void run_once ()
 
InterThreadTransportertransporter () 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. More...
 
void thread_quit ()
 
bool alive ()
 

Additional Inherited Members

- Public Types inherited from goby::middleware::Application< Config >
using ConfigType = Config
 
- Public Types inherited from goby::middleware::Thread< Config, InterThreadTransporter >
using Transporter = InterThreadTransporter
 
- Static Public Attributes inherited from goby::middleware::Thread< Config, InterThreadTransporter >
static constexpr goby::middleware::Group shutdown_group_
 
static constexpr goby::middleware::Group joinable_group_
 
- Protected Types inherited from goby::middleware::MultiThreadApplicationBase< Config, InterThreadTransporter >
using MainThreadBase = Thread< Config, InterThreadTransporter >
 

Detailed Description

template<class Config>
class goby::middleware::MultiThreadTest< Config >

Base class for building multithreaded Goby tests that do not have perform any interprocess (or outer) communications, but only communicate internally via the InterThreadTransporter. The only difference with this class and MultiThreadStandaloneApplication is that the interprocess() and intervehicle() methods are implemented here (as dummy calls to interthread()) to allow this to be a drop-in replacement for testing interthread comms on existing MultiThreadApplication subclasses.

Template Parameters
ConfigConfiguration type

Definition at line 381 of file multi_thread.h.

Constructor & Destructor Documentation

◆ MultiThreadTest()

template<class Config >
goby::middleware::MultiThreadTest< Config >::MultiThreadTest ( boost::units::quantity< boost::units::si::frequency >  loop_freq = 0 * boost::units::si::hertz)
inline

Construct the test running at the given frequency.

Parameters
loop_freqThe frequency at which to attempt to call loop(), assuming the main thread isn't blocked handling transporter callbacks (e.g. subscribe callbacks). Zero or negative indicates loop() will never be called.

Definition at line 390 of file multi_thread.h.

◆ ~MultiThreadTest()

template<class Config >
virtual goby::middleware::MultiThreadTest< Config >::~MultiThreadTest ( )
inlinevirtual

Definition at line 395 of file multi_thread.h.

Member Function Documentation

◆ interprocess()

template<class Config >
InterThreadTransporter& goby::middleware::MultiThreadTest< Config >::interprocess ( )
inlineprotected

Definition at line 399 of file multi_thread.h.

◆ intervehicle()

template<class Config >
InterThreadTransporter& goby::middleware::MultiThreadTest< Config >::intervehicle ( )
inlineprotected

Definition at line 400 of file multi_thread.h.


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