1 #ifndef GAUDIKERNEL_WATCHDOGTHREAD_H_ 2 #define GAUDIKERNEL_WATCHDOGTHREAD_H_ 6 #include <boost/date_time/posix_time/posix_time_types.hpp> 7 #include <boost/thread/mutex.hpp> 8 #include <boost/thread/thread_time.hpp> 35 WatchdogThread( boost::posix_time::time_duration timeout,
bool autostart =
false );
50 boost::mutex::scoped_lock lock( m_lastPingMutex );
51 m_lastPing = boost::get_system_time();
56 inline void setTimeout( boost::posix_time::time_duration timeout ) { m_timeout = timeout; }
59 inline boost::posix_time::time_duration
getTimeout()
const {
return m_timeout; }
64 boost::mutex::scoped_lock lock( m_lastPingMutex );
73 virtual void onPing();
76 virtual void onStart();
79 virtual void onStop();
boost::posix_time::time_duration getTimeout() const
Get the current time-out value.
boost::system_time m_lastPing
When the last ping was received.
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.
void ping()
Function to call to notify the watchdog thread that we are still alive.
bool m_running
Flag to mark the thread as running/stopped (avoid possible race conditions).
Simple class for asynchronous check of time-out.
boost::mutex m_lastPingMutex
Mutex for the access to the m_lastPing data member.
std::unique_ptr< boost::thread > m_thread
Pointer to the running thread;.
boost::system_time getLastPing() const
Get the time of latest ping.