![]() |
The Gaudi Framework
master (1304469f)
|
Helper to periodically run asynchronous tasks. More...
#include </builds/gaudi/Gaudi/GaudiUtils/include/Gaudi/Utils/PeriodicAction.h>

Public Types | |
| using | clock = std::chrono::steady_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, unsigned int repetitions=0) | |
| 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 |
| unsigned int | m_repetitions |
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), anticipate the stop and specify a maximum number of repetitions (if >0).
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.
| using Gaudi::Utils::PeriodicAction::clock = std::chrono::steady_clock |
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, | ||
| unsigned int | repetitions = 0 ) |
Definition at line 16 of file PeriodicAction.cpp.
|
default |
| PeriodicAction::~PeriodicAction | ( | ) |
Definition at line 22 of file PeriodicAction.cpp.
|
default |
| void PeriodicAction::start | ( | ) |
Definition at line 24 of file PeriodicAction.cpp.
| void PeriodicAction::stop | ( | ) |
Definition at line 45 of file PeriodicAction.cpp.
|
private |
Definition at line 48 of file PeriodicAction.h.
|
private |
Definition at line 49 of file PeriodicAction.h.
|
private |
Definition at line 50 of file PeriodicAction.h.
|
private |
Definition at line 47 of file PeriodicAction.h.
|
private |
Definition at line 46 of file PeriodicAction.h.