The Gaudi Framework
master (37c0b60a)
|
Helper to periodically run asynchronous tasks. More...
#include </builds/gaudi/Gaudi/GaudiUtils/include/Gaudi/Utils/PeriodicAction.h>
Public Types | |
using | clock = std::chrono::system_clock |
using | time_point = clock::time_point |
using | callback_t = std::function< void()> |
Public Member Functions | |
PeriodicAction (callback_t callback, std::chrono::milliseconds period_duration, bool autostart=true) | |
PeriodicAction (PeriodicAction &&)=default | |
PeriodicAction & | operator= (PeriodicAction &&)=default |
~PeriodicAction () | |
void | start () |
void | stop () |
Private Attributes | |
std::thread | m_thread |
std::promise< void > | m_stop_thread |
callback_t | m_callback |
std::chrono::milliseconds | m_period_duration |
Helper to periodically run asynchronous tasks.
An instance of this starts a dedicated thread that periodically runs the user specified callback.
The thread starts as soon as the instance is created and it's automatically terminated (and joined) on destruction. It's also possible to defer the start (if requested at construction time) and anticipate the stop.
Definition at line 29 of file PeriodicAction.h.
using Gaudi::Utils::PeriodicAction::callback_t = std::function<void()> |
Definition at line 33 of file PeriodicAction.h.
Definition at line 31 of file PeriodicAction.h.
using Gaudi::Utils::PeriodicAction::time_point = clock::time_point |
Definition at line 32 of file PeriodicAction.h.
PeriodicAction::PeriodicAction | ( | callback_t | callback, |
std::chrono::milliseconds | period_duration, | ||
bool | autostart = true |
||
) |
Definition at line 16 of file PeriodicAction.cpp.
|
default |
PeriodicAction::~PeriodicAction | ( | ) |
Definition at line 21 of file PeriodicAction.cpp.
|
default |
void PeriodicAction::start | ( | ) |
Definition at line 23 of file PeriodicAction.cpp.
void PeriodicAction::stop | ( | ) |
Definition at line 41 of file PeriodicAction.cpp.
|
private |
Definition at line 47 of file PeriodicAction.h.
|
private |
Definition at line 48 of file PeriodicAction.h.
|
private |
Definition at line 46 of file PeriodicAction.h.
|
private |
Definition at line 45 of file PeriodicAction.h.