Loading [MathJax]/extensions/tex2jax.js
Go to the documentation of this file.
11 #ifndef GAUDIKERNEL_WATCHDOGTHREAD_H_
12 #define GAUDIKERNEL_WATCHDOGTHREAD_H_
17 #include "boost/date_time/posix_time/posix_time_types.hpp"
18 #include "boost/thread/thread_time.hpp"
43 WatchdogThread( boost::posix_time::time_duration timeout,
bool autostart =
false );
57 auto lock = std::scoped_lock{ m_lastPingMutex };
58 m_lastPing = boost::get_system_time();
63 inline void setTimeout( boost::posix_time::time_duration timeout ) { m_timeout = timeout; }
66 inline boost::posix_time::time_duration
getTimeout()
const {
return m_timeout; }
70 auto lock = std::scoped_lock{ m_lastPingMutex };
79 virtual void onPing();
82 virtual void onStart();
85 virtual void onStop();
void ping()
Function to call to notify the watchdog thread that we are still alive.
boost::posix_time::time_duration getTimeout() const
Get the current time-out value.
bool m_running
Flag to mark the thread as running/stopped (avoid possible race conditions).
std::mutex m_lastPingMutex
Mutex for the access to the m_lastPing data member.
boost::system_time getLastPing() const
Get the time of latest ping.
void setTimeout(boost::posix_time::time_duration timeout)
Change the duration of the time-out.
boost::posix_time::time_duration m_timeout
Number of seconds allowed between pings.
std::unique_ptr< boost::thread > m_thread
Pointer to the running thread;.
boost::system_time m_lastPing
When the last ping was received.