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_ &&
94 this->
interprocess().template publish<groups::health_response>(health_response_);
96 waiting_for_responses_ =
false;
97 child_responses_.clear();
98 health_response_.
Clear();
104 protobuf::ProcessHealth health_response_;
106 std::map<int, std::shared_ptr<const protobuf::ThreadHealth>> child_responses_;
109 bool waiting_for_responses_{
false};
SimpleThread(const NullConfig &cfg, double loop_freq_hertz=0, int index=-1)
InterThreadTransporter & interthread()
InterProcessForwarder< InterThreadTransporter, ImplementationTag > & interprocess()
virtual void initialize()
void set_name(const std::string &name)
void thread_health(goby::middleware::protobuf::ThreadHealth &health)
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final
bool IsInitialized() const final
::goby::middleware::protobuf::ThreadHealth * mutable_main()
const ::goby::middleware::protobuf::ThreadHealth & main() const
::goby::middleware::protobuf::ThreadHealth * mutable_child(int index)
void set_state(::goby::middleware::protobuf::HealthState value)
::goby::middleware::protobuf::HealthState state() const
Objects implementing the Goby nested middleware.
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.