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