The Gaudi Framework
v30r3 (a5ef0a68)
|
Simple class for asynchronous check of time-out. More...
#include <GaudiKernel/WatchdogThread.h>
Public Member Functions | |
WatchdogThread (boost::posix_time::time_duration timeout, bool autostart=false) | |
Constructor. More... | |
virtual | ~WatchdogThread () |
Destructor. More... | |
void | start () |
Start the watchdog thread. More... | |
void | stop () |
Signal the watchdog thread to stop and wait for it. More... | |
void | ping () |
Function to call to notify the watchdog thread that we are still alive. More... | |
void | setTimeout (boost::posix_time::time_duration timeout) |
Change the duration of the time-out. More... | |
boost::posix_time::time_duration | getTimeout () const |
Get the current time-out value. More... | |
boost::system_time | getLastPing () const |
Get the time of latest ping. More... | |
Protected Member Functions | |
virtual void | action () |
User implemented function that will be called if the time-out is reached. More... | |
virtual void | onPing () |
User implemented function that will be called when ping is called. More... | |
virtual void | onStart () |
User implemented function that will be called when starting. More... | |
virtual void | onStop () |
User implemented function that will be called when stopping. More... | |
Private Member Functions | |
void | i_run () |
Core function of the secondary thread. More... | |
Private Attributes | |
boost::posix_time::time_duration | m_timeout |
Number of seconds allowed between pings. More... | |
boost::system_time | m_lastPing |
When the last ping was received. More... | |
std::unique_ptr< boost::thread > | m_thread |
Pointer to the running thread;. More... | |
bool | m_running |
Flag to mark the thread as running/stopped (avoid possible race conditions). More... | |
boost::mutex | m_lastPingMutex |
Mutex for the access to the m_lastPing data member. More... | |
Simple class for asynchronous check of time-out.
The user must provide a callable with the action to be performed when the time-out occurs.
Definition at line 28 of file WatchdogThread.h.
WatchdogThread::WatchdogThread | ( | boost::posix_time::time_duration | timeout, |
bool | autostart = false |
||
) |
Constructor.
Definition at line 12 of file WatchdogThread.cpp.
|
virtual |
Destructor.
Definition at line 19 of file WatchdogThread.cpp.
|
protectedvirtual |
User implemented function that will be called if the time-out is reached.
Definition at line 84 of file WatchdogThread.cpp.
|
inline |
Get the time of latest ping.
Definition at line 62 of file WatchdogThread.h.
|
inline |
Get the current time-out value.
Definition at line 59 of file WatchdogThread.h.
|
private |
Core function of the secondary thread.
Definition at line 51 of file WatchdogThread.cpp.
|
protectedvirtual |
User implemented function that will be called when ping is called.
Definition at line 87 of file WatchdogThread.cpp.
|
protectedvirtual |
User implemented function that will be called when starting.
Definition at line 90 of file WatchdogThread.cpp.
|
protectedvirtual |
User implemented function that will be called when stopping.
Definition at line 93 of file WatchdogThread.cpp.
|
inline |
Function to call to notify the watchdog thread that we are still alive.
Definition at line 48 of file WatchdogThread.h.
|
inline |
Change the duration of the time-out.
Definition at line 56 of file WatchdogThread.h.
void WatchdogThread::start | ( | ) |
Start the watchdog thread.
Definition at line 25 of file WatchdogThread.cpp.
void WatchdogThread::stop | ( | ) |
Signal the watchdog thread to stop and wait for it.
Definition at line 38 of file WatchdogThread.cpp.
|
private |
When the last ping was received.
Definition at line 86 of file WatchdogThread.h.
|
mutableprivate |
Mutex for the access to the m_lastPing data member.
Definition at line 100 of file WatchdogThread.h.
|
private |
Flag to mark the thread as running/stopped (avoid possible race conditions).
Definition at line 92 of file WatchdogThread.h.
|
private |
Pointer to the running thread;.
Definition at line 89 of file WatchdogThread.h.
|
private |
Number of seconds allowed between pings.
Definition at line 83 of file WatchdogThread.h.