Goby3
3.1.5a
2024.05.23
|
Represents a thread of execution within the Goby middleware, interleaving periodic events (loop()) with asynchronous receipt of data. Most user code should inherit from SimpleThread, not from Thread directly. More...
#include <goby/middleware/application/thread.h>
Public Types | |
using | Transporter = TransporterType |
Public Member Functions | |
Thread (const Config &cfg, TransporterType *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, TransporterType *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, TransporterType *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) |
Static Public Attributes | |
static constexpr goby::middleware::Group | shutdown_group_ {"goby::middleware::Thread::shutdown"} |
static constexpr goby::middleware::Group | joinable_group_ {"goby::middleware::Thread::joinable"} |
Protected Member Functions | |
Thread (const Config &cfg, boost::units::quantity< boost::units::si::frequency > loop_freq, int index=-1) | |
void | set_transporter (TransporterType *transporter) |
virtual void | loop () |
double | loop_frequency_hertz () const |
decltype(loop_frequency_) | loop_frequency () const |
double | loop_max_frequency () const |
void | run_once () |
TransporterType & | 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. More... | |
void | thread_quit () |
bool | alive () |
Represents a thread of execution within the Goby middleware, interleaving periodic events (loop()) with asynchronous receipt of data. Most user code should inherit from SimpleThread, not from Thread directly.
A Thread can represent the main thread of an application or a thread that was launched after startup.
Config | Type of the configuration for thie code running in this Thread |
TransporterType | Type of the underlying transporter used for publish/subscribe from this thread |
using goby::middleware::Thread< Config, TransporterType >::Transporter = TransporterType |
|
inline |
Construct a thread with a given configuration, underlying transporter, and index (for multiple instantiations), but without any loop() frequency.
|
inline |
Construct a thread with all possible metadata (using double to specify frequency in Hertz)
cfg | Data to configure the code running in this thread |
transporter | Underlying transporter |
loop_freq_hertz | The frequency at which to attempt to call loop(), assuming the thread isn't blocked handling transporter callbacks (e.g. subscribe callbacks) |
index | Numeric index to identify this instantiation of the Thread (only necessary if multiple Threads of the same type are created) |
|
inline |
Construct a thread with all possible metadata (using boost::units to specify frequency)
cfg | Data to configure the code running in this thread |
transporter | Underlying transporter |
loop_freq | The frequency at which to attempt to call loop(), assuming the thread isn't blocked handling transporter callbacks (i.e. subscribe callbacks) |
index | Numeric index to identify this instantiation of the Thread (only necessary if multiple Threads of the same type are created) |
|
inlinevirtual |
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
|
inlineprotectedvirtual |
Reimplemented in goby::middleware::io::detail::IOThread< line_in_group, line_out_group, PubSubLayer::INTERPROCESS, PubSubLayer::INTERTHREAD, goby::middleware::protobuf::PTYConfig, boost::asio::posix::stream_descriptor, goby::middleware::SimpleThread, false >, goby::middleware::io::detail::IOThread< line_in_group, line_out_group, PubSubLayer::INTERPROCESS, PubSubLayer::INTERTHREAD, goby::middleware::protobuf::CanConfig, boost::asio::posix::stream_descriptor, goby::middleware::SimpleThread, false >, goby::middleware::io::detail::IOThread< line_in_group, line_out_group, publish_layer, subscribe_layer, goby::middleware::protobuf::TCPClientConfig, boost::asio::ip::tcp::socket, goby::middleware::SimpleThread, use_indexed_groups >, goby::middleware::io::detail::IOThread< line_in_group, line_out_group, publish_layer, subscribe_layer, goby::middleware::protobuf::SerialConfig, boost::asio::serial_port, goby::middleware::SimpleThread, use_indexed_groups >, goby::middleware::io::detail::IOThread< line_in_group, line_out_group, PubSubLayer::INTERPROCESS, PubSubLayer::INTERTHREAD, goby::middleware::protobuf::UDPOneToManyConfig, boost::asio::ip::udp::socket, goby::middleware::SimpleThread, false >, goby::middleware::io::detail::IOThread< line_in_group, line_out_group, publish_layer, subscribe_layer, goby::middleware::protobuf::PTYConfig, boost::asio::posix::stream_descriptor, goby::middleware::SimpleThread, use_indexed_groups >, goby::middleware::io::detail::IOThread< line_in_group, line_out_group, publish_layer, subscribe_layer, goby::middleware::protobuf::TCPServerConfig, boost::asio::ip::tcp::acceptor, goby::middleware::SimpleThread, use_indexed_groups >, and goby::middleware::io::detail::IOThread< line_in_group, line_out_group, publish_layer, subscribe_layer, goby::middleware::protobuf::UDPPointToPointConfig, boost::asio::ip::udp::socket, goby::middleware::SimpleThread, use_indexed_groups >.
|
inlineprotectedvirtual |
Called when HealthRequest is made by goby_coroner.
Override to implement thread specific health response
Reimplemented in goby::middleware::MultiThreadApplication< Config, InterProcessPortal >, and goby::middleware::SingleThreadApplication< Config, InterProcessPortal >.
|
inline |
|
inlineprotectedvirtual |
Reimplemented in goby::middleware::io::detail::IOThread< line_in_group, line_out_group, PubSubLayer::INTERPROCESS, PubSubLayer::INTERTHREAD, goby::middleware::protobuf::PTYConfig, boost::asio::posix::stream_descriptor, goby::middleware::SimpleThread, false >, goby::middleware::io::detail::IOThread< line_in_group, line_out_group, PubSubLayer::INTERPROCESS, PubSubLayer::INTERTHREAD, goby::middleware::protobuf::CanConfig, boost::asio::posix::stream_descriptor, goby::middleware::SimpleThread, false >, goby::middleware::io::detail::IOThread< line_in_group, line_out_group, publish_layer, subscribe_layer, goby::middleware::protobuf::TCPClientConfig, boost::asio::ip::tcp::socket, goby::middleware::SimpleThread, use_indexed_groups >, goby::middleware::io::detail::IOThread< line_in_group, line_out_group, publish_layer, subscribe_layer, goby::middleware::protobuf::SerialConfig, boost::asio::serial_port, goby::middleware::SimpleThread, use_indexed_groups >, goby::middleware::io::detail::IOThread< line_in_group, line_out_group, PubSubLayer::INTERPROCESS, PubSubLayer::INTERTHREAD, goby::middleware::protobuf::UDPOneToManyConfig, boost::asio::ip::udp::socket, goby::middleware::SimpleThread, false >, goby::middleware::io::detail::IOThread< line_in_group, line_out_group, publish_layer, subscribe_layer, goby::middleware::protobuf::PTYConfig, boost::asio::posix::stream_descriptor, goby::middleware::SimpleThread, use_indexed_groups >, goby::middleware::io::detail::IOThread< line_in_group, line_out_group, publish_layer, subscribe_layer, goby::middleware::protobuf::TCPServerConfig, boost::asio::ip::tcp::acceptor, goby::middleware::SimpleThread, use_indexed_groups >, and goby::middleware::io::detail::IOThread< line_in_group, line_out_group, publish_layer, subscribe_layer, goby::middleware::protobuf::UDPPointToPointConfig, boost::asio::ip::udp::socket, goby::middleware::SimpleThread, use_indexed_groups >.
|
inlineprotectedvirtual |
Reimplemented in goby::zeromq::LiaisonCommsThread< WtContainer >, and goby::middleware::intervehicle::ModemDriverThread.
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
|
inline |
|
inline |
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.
alive | Reference to an atomic boolean. While alive is true, the thread will run; when alive is set false, the thread will complete (and become joinable), assuming nothing is blocking loop() or any transporter callback. |
|
protected |
|
inline |
|
inlineprotected |
|
inline |
|
inline |
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
|
inline |
|
inline |
|
staticconstexpr |
|
staticconstexpr |