ADTF
3.18.2
|
Periodic timer running in a separate thread. More...
Classes | |
class | IntrusivePtr |
Public Member Functions | |
Timer () | |
Default CTOR. | |
~Timer () | |
DTOR - Calls stop() | |
Timer (std::uint64_t period_us, void(*function)()) | |
CTOR for functions as callbacks. More... | |
template<typename M , typename T > | |
Timer (std::uint64_t period_us, M method, T &instance) | |
CTOR for methods as callbacks. More... | |
void | setCallback (void(*function)()) |
Set the callback for the timer. More... | |
template<typename M , typename T > | |
void | setCallback (M method, T &instance) |
Set the callback for the timer. More... | |
void | setPeriod (std::uint64_t period_us) |
Set the period used by this timer, restarting the timer if already running. More... | |
std::uint64_t | getPeriod () const |
Get the currently configured period of the timer. More... | |
bool | start () |
Start the timer. More... | |
bool | stop () |
Stop the timer - blocks until the callback returns. More... | |
bool | isRunning () const |
Check whether the timer is currently running. More... | |
Private Member Functions | |
Timer (const Timer &) | |
Timer & | operator= (const Timer &) |
void | setCallback (const a_util::experimental::NullaryDelegate< void > &cb) |
Static Private Member Functions | |
template<typename T , typename... Args> | |
static auto | makeIntrusive (Args &&... args) -> IntrusivePtr< T > |
Private Attributes | |
IntrusivePtr< Implementation > | _impl |
Periodic timer running in a separate thread.
Definition at line 45 of file timer_decl.h.
Timer | ( | std::uint64_t | period_us, |
void(*)() | function | ||
) |
CTOR for functions as callbacks.
To start the timer, call start
[in] | period_us | Duration between calls to function (in microseconds) 0 -> One shot timer |
[in] | function | Pointer to callback function |
|
inline |
CTOR for methods as callbacks.
To start the timer, call start
M | Method type to call |
T | Class containing the method |
[in] | period_us | Duration between calls to function (in microseconds). 0 -> One shot timer |
[in] | method | Method used as callback |
[in] | instance | Instance of the class the method to invoke from |
Definition at line 24 of file timer_impl.h.
References Timer::setCallback(), and Timer::setPeriod().
std::uint64_t getPeriod | ( | ) | const |
Get the currently configured period of the timer.
bool isRunning | ( | ) | const |
Check whether the timer is currently running.
true
if timer is running, false
otherwise
|
inline |
Set the callback for the timer.
M | Method type to call |
T | Class containing the method |
[in] | method | Method used as callback |
[in] | instance | Instance of the class the method to invoke from |
Definition at line 32 of file timer_impl.h.
References Timer::setCallback().
void setCallback | ( | void(*)() | function | ) |
Set the callback for the timer.
[in] | function | Pointer to callback function |
Referenced by Timer::Timer(), and Timer::setCallback().
void setPeriod | ( | std::uint64_t | period_us | ) |
Set the period used by this timer, restarting the timer if already running.
[in] | period_us | Duration in microseconds between invocations of callback function. 0 -> One shot timer |
Referenced by Timer::Timer().
bool start | ( | ) |
Start the timer.
true
on success, false
if the timer is already running bool stop | ( | ) |
Stop the timer - blocks until the callback returns.
true
on success, false
if the timer is already stopped