RTC Toolkit 6.0.0
Loading...
Searching...
No Matches
rtcMonitor.hpp
Go to the documentation of this file.
1
11
12#ifndef RTCTK_RTCSUPERVISOR_RTCMONITOR_HPP
13#define RTCTK_RTCSUPERVISOR_RTCMONITOR_HPP
14
16
17#include <atomic>
18#include <chrono>
19#include <functional>
20#include <thread>
21
22#include <boost/asio.hpp>
23
24namespace rtctk::rtcSupervisor {
25
27public:
28 using MonitorFunction = std::function<void()>; // noexcept function (C++17 has problems here)
29
30 explicit RtcMonitor(MonitorFunction func);
31 virtual ~RtcMonitor();
32
34 void Run();
35
37 void Idle();
38
43 boost::asio::io_context& GetIoContext() {
44 return m_io_context;
45 }
46
47private:
48 void Work();
49
50 log4cplus::Logger& m_logger;
51 std::chrono::microseconds m_interval;
52 MonitorFunction m_mon_func;
53 std::atomic<bool> m_time_to_stop;
54 std::atomic<bool> m_mon_active;
56 boost::asio::io_context m_io_context;
57 std::thread m_thread;
58};
59
60} // namespace rtctk::rtcSupervisor
61
62#endif // RTCTK_RTCSUPERVISOR_RTCMONITOR_HPP
void Run()
start monitoring
Definition rtcMonitor.cpp:43
RtcMonitor(MonitorFunction func)
Definition rtcMonitor.cpp:22
boost::asio::io_context & GetIoContext()
Get the I/O context object to be able to use this thread with boost::asio.
Definition rtcMonitor.hpp:43
void Idle()
stop monitoring
Definition rtcMonitor.cpp:49
virtual ~RtcMonitor()
Definition rtcMonitor.cpp:31
std::function< void()> MonitorFunction
Definition rtcMonitor.hpp:28
Logging Support Library based on log4cplus.
Definition alertAggregator.cpp:18