The Timer class provides repetitive and single-shot timers.
More...
#include <timer.h>
|
| static std::shared_ptr< Timer > | create () |
| | Creates a new Timer object, the timer is not started at this point. More...
|
| |
| static uint64_t | now () |
| |
The Timer class provides repetitive and single-shot timers.
Provides a high level interface for timers. To use it, create a Timer and connect a slot to its
- See also
- sigExpired signal.
The timeout slot will now be called every second.
- Note
- The accuracy of the timer should be around 1ms , but also depends on the underlying hardware.
Definition at line 42 of file timer.h.
◆ Ptr
◆ WeakPtr
◆ ~Timer()
| zyppng::Timer::~Timer |
( |
| ) |
|
|
virtual |
◆ Timer()
◆ create()
| std::shared_ptr< Timer > zyppng::Timer::create |
( |
| ) |
|
|
static |
Creates a new Timer object, the timer is not started at this point.
Definition at line 46 of file timer.cc.
◆ setSingleShot()
| void zyppng::Timer::setSingleShot |
( |
bool |
singleShot = true | ) |
|
Sets the timer to trigger only once, after it has expired once.
- See also
- start needs to be called again
Definition at line 54 of file timer.cc.
◆ singleShot()
| bool zyppng::Timer::singleShot |
( |
| ) |
const |
- Returns
- true if the timer is a single shot timer
Definition at line 59 of file timer.cc.
◆ now()
| uint64_t zyppng::Timer::now |
( |
| ) |
|
|
static |
- Returns
- The current monotonic system time in milliseconds
Definition at line 64 of file timer.cc.
◆ started()
| uint64_t zyppng::Timer::started |
( |
| ) |
const |
- Returns
- the monotonic system time when the timer started
Definition at line 77 of file timer.cc.
◆ interval()
| uint64_t zyppng::Timer::interval |
( |
| ) |
const |
- Returns
- the requested interval in milliseconds
Definition at line 82 of file timer.cc.
◆ remaining()
| uint64_t zyppng::Timer::remaining |
( |
| ) |
const |
- Returns
- the remaining time until the timer expires in milliseconds
Definition at line 87 of file timer.cc.
◆ elapsed()
| uint64_t zyppng::Timer::elapsed |
( |
| ) |
const |
- Returns
- the time that has elapsed since the last call to start in milliseconds
Definition at line 97 of file timer.cc.
◆ expires()
| uint64_t zyppng::Timer::expires |
( |
| ) |
const |
- Returns
- the monotonic system time in ms when the timer is about to expire
Definition at line 104 of file timer.cc.
◆ expire()
| uint64_t zyppng::Timer::expire |
( |
| ) |
|
Advances the internal clock of the timer, if the timer expires the sigExpired signal is emitted.
- Returns
- the monotonic system time in ms when the timer is about to expire
- Note
- There should not be any reason to call this manually, the
- See also
- EventDispatcher is taking care of that
Definition at line 114 of file timer.cc.
◆ isRunning()
| bool zyppng::Timer::isRunning |
( |
| ) |
const |
- Returns
- if the timer is currently active
Definition at line 133 of file timer.cc.
◆ start() [1/2]
| void zyppng::Timer::start |
( |
| ) |
|
Starts the timer, if the timer is already running this will restart the currently running timer
Definition at line 138 of file timer.cc.
◆ start() [2/2]
| void zyppng::Timer::start |
( |
uint64_t |
timeout | ) |
|
Starts the timer, if the timer is already running this will restart the currently running timer.
- Parameters
-
| timeout | the new timeout in ms |
Definition at line 143 of file timer.cc.
◆ stop()
| void zyppng::Timer::stop |
( |
| ) |
|
Stops the timer if its running. The.
- See also
- sigExpired signal will not emit until
-
start was called again
Definition at line 162 of file timer.cc.
◆ sigExpired()
This signal is always emitted when the timer expires.
Definition at line 109 of file timer.cc.
◆ EventDispatcher
The documentation for this class was generated from the following files: