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

Base class for creating multiple thread applications. More...

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

Inheritance diagram for goby::middleware::MultiThreadApplicationBase< Config, Transporter >:
goby::middleware::Application< Config > goby::middleware::Thread< Config, Transporter >

Public Member Functions

template<typename ThreadType>
void launch_thread ()
template<typename ThreadType>
void launch_thread (int index)
template<typename ThreadType, typename ThreadConfig>
void launch_thread (const ThreadConfig &cfg)
template<typename ThreadType, typename ThreadConfig>
void launch_thread (int index, const ThreadConfig &cfg)
template<typename ThreadType>
void launch_thread_without_cfg ()
template<typename ThreadType>
void launch_thread_without_cfg (int index)
template<typename ThreadType>
void join_thread (int index=-1)
template<int i>
void launch_timer (boost::units::quantity< boost::units::si::frequency > freq, std::function< void()> on_expire)
template<int i>
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, Transporter >
 Thread (const Config &cfg, Transporter *transporter, int index)
 Construct a thread with a given configuration, underlying transporter, and index (for multiple instantiations), but without any loop() frequency.
 Thread (const Config &cfg, Transporter *transporter, double loop_freq_hertz=0, int index=-1)
 Construct a thread with all possible metadata (using double to specify frequency in Hertz).
 Thread (const Config &cfg, Transporter *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).
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)

Protected Types

using MainThreadBase = Thread<Config, Transporter>

Protected Member Functions

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

Additional Inherited Members

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

Detailed Description

template<class Config, class Transporter>
class goby::middleware::MultiThreadApplicationBase< Config, Transporter >

Base class for creating multiple thread applications.

Template Parameters
ConfigConfiguration type
TransporterTransporter type

Definition at line 99 of file multi_thread.h.

Member Typedef Documentation

◆ MainThreadBase

template<class Config, class Transporter>
using goby::middleware::MultiThreadApplicationBase< Config, Transporter >::MainThreadBase = Thread<Config, Transporter>
protected

Definition at line 189 of file multi_thread.h.

Constructor & Destructor Documentation

◆ MultiThreadApplicationBase()

template<class Config, class Transporter>
goby::middleware::MultiThreadApplicationBase< Config, Transporter >::MultiThreadApplicationBase ( boost::units::quantity< boost::units::si::frequency > loop_freq,
Transporter * transporter )
inlineprotected

Definition at line 191 of file multi_thread.h.

◆ ~MultiThreadApplicationBase()

template<class Config, class Transporter>
virtual goby::middleware::MultiThreadApplicationBase< Config, Transporter >::~MultiThreadApplicationBase ( )
inlineprotectedvirtual

Definition at line 203 of file multi_thread.h.

Member Function Documentation

◆ interthread()

template<class Config, class Transporter>
InterThreadTransporter & goby::middleware::MultiThreadApplicationBase< Config, Transporter >::interthread ( )
inlineprotected

Definition at line 205 of file multi_thread.h.

◆ join_all_threads()

template<class Config, class Transporter>
void goby::middleware::MultiThreadApplicationBase< Config, Transporter >::join_all_threads ( )
inlineprotected

Definition at line 210 of file multi_thread.h.

◆ join_thread()

template<class Config, class Transporter>
template<typename ThreadType>
void goby::middleware::MultiThreadApplicationBase< Config, Transporter >::join_thread ( int index = -1)
inline

Definition at line 160 of file multi_thread.h.

◆ join_timer()

template<class Config, class Transporter>
template<int i>
void goby::middleware::MultiThreadApplicationBase< Config, Transporter >::join_timer ( )
inline

Definition at line 184 of file multi_thread.h.

◆ launch_thread() [1/4]

template<class Config, class Transporter>
template<typename ThreadType>
void goby::middleware::MultiThreadApplicationBase< Config, Transporter >::launch_thread ( )
inline

Definition at line 131 of file multi_thread.h.

◆ launch_thread() [2/4]

template<class Config, class Transporter>
template<typename ThreadType, typename ThreadConfig>
void goby::middleware::MultiThreadApplicationBase< Config, Transporter >::launch_thread ( const ThreadConfig & cfg)
inline

Definition at line 141 of file multi_thread.h.

◆ launch_thread() [3/4]

template<class Config, class Transporter>
template<typename ThreadType>
void goby::middleware::MultiThreadApplicationBase< Config, Transporter >::launch_thread ( int index)
inline

Definition at line 135 of file multi_thread.h.

◆ launch_thread() [4/4]

template<class Config, class Transporter>
template<typename ThreadType, typename ThreadConfig>
void goby::middleware::MultiThreadApplicationBase< Config, Transporter >::launch_thread ( int index,
const ThreadConfig & cfg )
inline

Definition at line 146 of file multi_thread.h.

◆ launch_thread_without_cfg() [1/2]

template<class Config, class Transporter>
template<typename ThreadType>
void goby::middleware::MultiThreadApplicationBase< Config, Transporter >::launch_thread_without_cfg ( )
inline

Definition at line 151 of file multi_thread.h.

◆ launch_thread_without_cfg() [2/2]

template<class Config, class Transporter>
template<typename ThreadType>
void goby::middleware::MultiThreadApplicationBase< Config, Transporter >::launch_thread_without_cfg ( int index)
inline

Definition at line 155 of file multi_thread.h.

◆ launch_timer()

template<class Config, class Transporter>
template<int i>
void goby::middleware::MultiThreadApplicationBase< Config, Transporter >::launch_timer ( boost::units::quantity< boost::units::si::frequency > freq,
std::function< void()> on_expire )
inline

Definition at line 176 of file multi_thread.h.

◆ post_finalize()

template<class Config, class Transporter>
virtual void goby::middleware::MultiThreadApplicationBase< Config, Transporter >::post_finalize ( )
inlineoverrideprotectedvirtual

Called just after finalize.

Reimplemented from goby::middleware::Application< Config >.

Definition at line 206 of file multi_thread.h.

◆ running_thread_count()

template<class Config, class Transporter>
int goby::middleware::MultiThreadApplicationBase< Config, Transporter >::running_thread_count ( )
inline

Definition at line 186 of file multi_thread.h.

◆ threads()

template<class Config, class Transporter>
std::map< std::type_index, std::map< int, ThreadManagement > > & goby::middleware::MultiThreadApplicationBase< Config, Transporter >::threads ( )
inlineprotected

Definition at line 208 of file multi_thread.h.


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