24#ifndef GOBY_MIDDLEWARE_CORONER_HEALTH_MONITOR_THREAD_H
25#define GOBY_MIDDLEWARE_CORONER_HEALTH_MONITOR_THREAD_H
41template <
typename ImplementationTag>
49 this->
interprocess().template subscribe<groups::health_request, protobuf::HealthRequest>(
52 this->
interthread().template publish<groups::health_request>(
54 waiting_for_responses_ =
true;
59 child_responses_[our_response->uid()] = our_response;
63 this->
interthread().template subscribe<groups::health_response>(
64 [
this](std::shared_ptr<const protobuf::ProcessHealth> response)
65 { health_response_ = *response; });
68 this->
interthread().template subscribe<groups::health_response>(
69 [
this](std::shared_ptr<const protobuf::ThreadHealth> response)
70 { child_responses_[response->uid()] = response; });
76 if (waiting_for_responses_ &&
82 for (
auto&
thread_health : *health_response_.mutable_main()->mutable_child())
94 this->
interprocess().template publish<groups::health_response>(health_response_);
96 waiting_for_responses_ =
false;
97 child_responses_.clear();
98 health_response_.
Clear();
101 void initialize()
override { this->
set_name(
"health_monitor"); }
104 protobuf::ProcessHealth health_response_;
106 std::map<int, std::shared_ptr<const protobuf::ThreadHealth>> child_responses_;
109 bool waiting_for_responses_{
false};
Implements Thread for a three layer middleware setup ([ intervehicle [ interprocess [ interthread ] ]...
InterThreadTransporter & interthread()
Access the transporter on the interthread layer (this is the innermost transporter)
InterProcessForwarder< InterThreadTransporter, ImplementationTag > & interprocess()
Access the transporter on the interprocess layer (which wraps interthread)
void set_name(const std::string &name)
void thread_health(goby::middleware::protobuf::ThreadHealth &health)
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final
const ::goby::middleware::protobuf::ThreadHealth & main() const
bool IsInitialized() const final
::goby::middleware::protobuf::ThreadHealth * mutable_main()
void set_state(::goby::middleware::protobuf::HealthState value)
::goby::middleware::protobuf::HealthState state() const
The global namespace for the Goby project.
std::chrono::time_point< SteadyClock > time_point
static time_point now() noexcept
Returns the current steady time unless SimulatorSettings::using_sim_time == true in which case a simu...
std::chrono::microseconds duration
Duration type.