Loading [MathJax]/extensions/tex2jax.js
Go to the documentation of this file.
20 #include <boost/thread/thread.hpp>
23 : m_timeout(
std::move( timeout ) ), m_running( false ) {
25 if ( autostart )
start();
62 boost::system_time nextCheck = lastPing +
getTimeout();
70 boost::thread::sleep( nextCheck );
75 nextCheck = boost::get_system_time() +
getTimeout();
84 catch ( boost::thread_interrupted& ) {}
void stop()
Signal the watchdog thread to stop and wait for it.
void ping()
Function to call to notify the watchdog thread that we are still alive.
virtual ~WatchdogThread()
Destructor.
virtual void onPing()
User implemented function that will be called when ping is called.
boost::posix_time::time_duration getTimeout() const
Get the current time-out value.
virtual void onStart()
User implemented function that will be called when starting.
GAUDI_API void NanoSleep(long long nsec)
Small variation on the sleep function for nanoseconds sleep.
void start()
Start the watchdog thread.
bool m_running
Flag to mark the thread as running/stopped (avoid possible race conditions).
boost::system_time getLastPing() const
Get the time of latest ping.
virtual void action()
User implemented function that will be called if the time-out is reached.
std::unique_ptr< boost::thread > m_thread
Pointer to the running thread;.
void i_run()
Core function of the secondary thread.
WatchdogThread(boost::posix_time::time_duration timeout, bool autostart=false)
Constructor.
virtual void onStop()
User implemented function that will be called when stopping.