![]() |
The Gaudi Framework
v38r3 (c3fc9673)
|
#include </builds/gaudi/Gaudi/GaudiKernel/include/GaudiKernel/WatchdogThread.h>

Public Types | |
| using | clock = std::chrono::system_clock |
| using | time_point = std::chrono::time_point< clock > |
Public Member Functions | |
| WatchdogThread (std::chrono::seconds 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 (std::chrono::seconds timeout) |
| Change the duration of the time-out. More... | |
| std::chrono::seconds | getTimeout () const |
| Get the current time-out value. More... | |
| time_point | 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 Attributes | |
| std::chrono::seconds | m_timeout |
| Number of seconds allowed between pings. More... | |
| std::atomic< time_point > | m_lastPing |
| When the last ping was received. More... | |
| std::thread | m_thread |
| Running thread;. More... | |
| std::promise< void > | m_stop_thread |
| Flag to mark the thread as running/stopped (avoid possible race conditions). 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 27 of file WatchdogThread.h.
Definition at line 29 of file WatchdogThread.h.
Definition at line 30 of file WatchdogThread.h.
| WatchdogThread::WatchdogThread | ( | std::chrono::seconds | timeout, |
| bool | autostart = false |
||
| ) |
Constructor.
Definition at line 18 of file WatchdogThread.cpp.
|
virtual |
Destructor.
Definition at line 23 of file WatchdogThread.cpp.
|
protectedvirtual |
User implemented function that will be called if the time-out is reached.
Definition at line 70 of file WatchdogThread.cpp.
|
inline |
|
inline |
|
protectedvirtual |
User implemented function that will be called when ping is called.
Definition at line 73 of file WatchdogThread.cpp.
|
protectedvirtual |
User implemented function that will be called when starting.
Definition at line 76 of file WatchdogThread.cpp.
|
protectedvirtual |
User implemented function that will be called when stopping.
Definition at line 79 of file WatchdogThread.cpp.
|
inline |
Function to call to notify the watchdog thread that we are still alive.
Definition at line 49 of file WatchdogThread.h.
|
inline |
| void WatchdogThread::start | ( | ) |
| void WatchdogThread::stop | ( | ) |
Signal the watchdog thread to stop and wait for it.
Definition at line 60 of file WatchdogThread.cpp.
|
private |
When the last ping was received.
Definition at line 81 of file WatchdogThread.h.
|
private |
Flag to mark the thread as running/stopped (avoid possible race conditions).
Definition at line 87 of file WatchdogThread.h.
|
private |
Running thread;.
Definition at line 84 of file WatchdogThread.h.
|
private |
Number of seconds allowed between pings.
Definition at line 78 of file WatchdogThread.h.