#include <timer_decl.h>
|
|
| Timer () |
| | Default CTOR.
|
| |
|
| ~Timer () |
| | DTOR - Calls stop()
|
| |
| | Timer (std::uint64_t period_us, void(*function)()) |
| |
| template<typename M, typename T> |
| | Timer (std::uint64_t period_us, M method, T &instance) |
| |
| void | setCallback (void(*function)()) |
| |
| template<typename M, typename T> |
| void | setCallback (M method, T &instance) |
| |
| void | setPeriod (std::uint64_t period_us) |
| |
| std::uint64_t | getPeriod () const |
| |
| bool | start () |
| |
| bool | stop () |
| |
| bool | isRunning () const |
| |
Periodic timer running in a separate thread
- Invokes a callback periodically
- If an invocation takes longer than the period, any missed expirations are lost!
- The callback is invoked from a different thread, take care about thread safety!
◆ Timer() [1/2]
| a_util::system::Timer::Timer |
( |
std::uint64_t | period_us, |
|
|
void(* | function )() ) |
CTOR for functions as callbacks
To start the timer, call start
- Parameters
-
| [in] | period_us | Duration between calls to function (in microseconds) 0 -> One shot timer |
| [in] | function | Pointer to callback function |
◆ Timer() [2/2]
template<typename M, typename T>
| a_util::system::Timer::Timer |
( |
std::uint64_t | period_us, |
|
|
M | method, |
|
|
T & | instance ) |
|
inline |
CTOR for methods as callbacks
To start the timer, call start
- Template Parameters
-
| M | Method type to call |
| T | Class containing the method |
- Parameters
-
| [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 |
◆ getPeriod()
| std::uint64_t a_util::system::Timer::getPeriod |
( |
| ) |
const |
Get the currently configured period of the timer
- Returns
- Period of the timer in microseconds
◆ isRunning()
| bool a_util::system::Timer::isRunning |
( |
| ) |
const |
Check whether the timer is currently running
- Returns
true if timer is running, false otherwise
◆ setCallback() [1/2]
template<typename M, typename T>
| void a_util::system::Timer::setCallback |
( |
M | method, |
|
|
T & | instance ) |
|
inline |
Set the callback for the timer
- Template Parameters
-
| M | Method type to call |
| T | Class containing the method |
- Parameters
-
| [in] | method | Method used as callback |
| [in] | instance | Instance of the class the method to invoke from |
◆ setCallback() [2/2]
| void a_util::system::Timer::setCallback |
( |
void(* | function )() | ) |
|
Set the callback for the timer
- Parameters
-
| [in] | function | Pointer to callback function |
◆ setPeriod()
| void a_util::system::Timer::setPeriod |
( |
std::uint64_t | period_us | ) |
|
Set the period used by this timer, restarting the timer if already running
- Parameters
-
| [in] | period_us | Duration in microseconds between invocations of callback function. 0 -> One shot timer |
◆ start()
| bool a_util::system::Timer::start |
( |
| ) |
|
Start the timer
- Returns
true on success, false if the timer is already running
◆ stop()
| bool a_util::system::Timer::stop |
( |
| ) |
|
Stop the timer - blocks until the callback returns
- Returns
true on success, false if the timer is already stopped
The documentation for this class was generated from the following files: