RTC Toolkit  2.0.0
rtcMonitor.hpp
Go to the documentation of this file.
1 
12 #ifndef RTCTK_RTCSUPERVISOR_RTCMONITOR_HPP
13 #define RTCTK_RTCSUPERVISOR_RTCMONITOR_HPP
14 
15 #include <atomic>
16 #include <boost/asio.hpp>
17 #include <boost/thread.hpp>
18 
19 namespace rtctk::rtcSupervisor {
20 
21 class RtcSupervisor;
22 
23 class RtcMonitor {
24 public:
25  RtcMonitor(RtcSupervisor *parent);
26  virtual ~RtcMonitor();
28  void StartMonitor();
30  void StopMonitor();
32  void StopThread();
33  void svc();
34 
39  boost::asio::io_context &GetIoContext() {
40  return m_io_context;
41  }
42 
43 protected:
44  void monitor();
45 
46 private:
47  int m_sleepusec;
48  RtcSupervisor *mp_supervisor;
49  std::atomic<bool> m_time_to_stop;
50  std::atomic<bool> m_mon_active;
51  boost::thread m_the_thread;
53  boost::asio::io_context m_io_context;
54 };
55 
56 } // namespace rtctk::rtcSupervisor
57 
58 #endif // RTCTK_RTCSUPERVISOR_RTCMONITOR_HPP
rtctk::rtcSupervisor
Definition: rtcCommandRequest.hpp:19
rtctk::rtcSupervisor::RtcMonitor::StopMonitor
void StopMonitor()
stop monitoring
Definition: rtcMonitor.cpp:62
rtctk::rtcSupervisor::RtcMonitor::~RtcMonitor
virtual ~RtcMonitor()
Definition: rtcMonitor.cpp:43
rtctk::rtcSupervisor::RtcMonitor::GetIoContext
boost::asio::io_context & GetIoContext()
Get the I/O context object to be able to use this thread with boost::asio.
Definition: rtcMonitor.hpp:39
rtctk::rtcSupervisor::RtcMonitor::RtcMonitor
RtcMonitor(RtcSupervisor *parent)
Definition: rtcMonitor.cpp:32
rtctk::rtcSupervisor::RtcMonitor::monitor
void monitor()
Definition: rtcMonitor.cpp:110
rtctk::rtcSupervisor::RtcMonitor::StopThread
void StopThread()
inform the thread to stop execution
Definition: rtcMonitor.cpp:68
rtctk::rtcSupervisor::RtcSupervisor
Definition: rtcSupervisor.hpp:35
rtctk::rtcSupervisor::RtcMonitor::svc
void svc()
Definition: rtcMonitor.cpp:74
rtctk::rtcSupervisor::RtcMonitor
Definition: rtcMonitor.hpp:23
rtctk::rtcSupervisor::RtcMonitor::StartMonitor
void StartMonitor()
start monitoring
Definition: rtcMonitor.cpp:56