#include <timers.h>
Inheritance diagram for ucommon::Timer:
Public Types | |
typedef uint64_t | tick_t |
Public Member Functions | |
void | clear (void) |
Clear pending timer, has no value. | |
timeout_t | get (void) |
Get remaining time until the timer expires. | |
timeout_t | operator * () |
Get remaining time until timer expires by reference. | |
operator bool () | |
Check if timer expired for is() expression. | |
bool | operator! () |
Check if timer has expired. | |
bool | operator!= (Timer &timer) |
Compare timers if not same timeout. | |
Timer & | operator+= (timeout_t expire) |
Adjust timer expiration. | |
Timer & | operator+= (time_t expire) |
Adjust timer expiration. | |
timeout_t | operator- (Timer &timer) |
Compute difference between two timers. | |
Timer & | operator-= (timeout_t expire) |
Adjust timer expiration. | |
Timer & | operator-= (time_t expire) |
Adjust timer expiration. | |
bool | operator< (Timer &timer) |
Compare timers if earlier timeout than another timer. | |
bool | operator<= (Timer &timer) |
Compare timers if earlier than or equal to another timer. | |
Timer & | operator= (timeout_t expire) |
Set timer expiration. | |
Timer & | operator= (time_t expire) |
Set timer expiration. | |
bool | operator== (Timer &timer) |
Compare timers if same timeout. | |
bool | operator> (Timer &timer) |
Compare timers if later timeout than another timer. | |
bool | operator>= (Timer &timer) |
Compare timers if later than or equal to another timer. | |
void | set (void) |
Set (update) the timer with current time. | |
void | set (time_t expire) |
Set the timer to expire. | |
void | set (timeout_t expire) |
Set the timer to expire. | |
Timer (Timer ©) | |
Construct a timer from a copy of another timer. | |
Timer (time_t offset) | |
Construct a triggered timer that expires at specified offset. | |
Timer (timeout_t offset) | |
Construct a triggered timer that expires at specified offset. | |
Timer () | |
Construct an untriggered timer set to the time of creation. | |
Static Public Member Functions | |
static void | sync (Timer &timer) |
Sleep current thread until the specified timer expires. | |
static tick_t | ticks (void) |
Get timer ticks since uuid epoch. | |
Static Public Attributes | |
static timeout_t | inf |
A value to use for infinite time. | |
static time_t | reset |
A value to use when resetting. | |
Protected Member Functions | |
bool | is_active (void) |
Check if timer active. | |
bool | update (void) |
Check if timer has been updated since last check. | |
Friends | |
class | Conditional |
class | Event |
class | Semaphore |
The timer generally uses millisecond values but has a microsecond accuracy. On platforms that support it, the timer uses posix realtime monotonic clock extensions, otherwise lower accuracy timer systems might be used.
Definition at line 49 of file timers.h.
ucommon::Timer::Timer | ( | timeout_t | offset | ) |
Construct a triggered timer that expires at specified offset.
offset | to expire in milliseconds. |
ucommon::Timer::Timer | ( | time_t | offset | ) |
Construct a triggered timer that expires at specified offset.
offset | to expire in seconds. |
ucommon::Timer::Timer | ( | Timer & | copy | ) |
Construct a timer from a copy of another timer.
copy | of timer to construct from. |
timeout_t ucommon::Timer::get | ( | void | ) |
Get remaining time until the timer expires.
Reimplemented in ucommon::TimerQueue::event.
bool ucommon::Timer::is_active | ( | void | ) | [protected] |
Check if timer active.
timeout_t ucommon::Timer::operator * | ( | ) | [inline] |
ucommon::Timer::operator bool | ( | ) |
bool ucommon::Timer::operator! | ( | ) |
Check if timer has expired.
bool ucommon::Timer::operator!= | ( | Timer & | timer | ) |
Compare timers if not same timeout.
timer | to compare with. |
Adjust timer expiration.
expire | time to add in milliseconds. |
Timer& ucommon::Timer::operator+= | ( | time_t | expire | ) |
Adjust timer expiration.
expire | time to add in seconds. |
Compute difference between two timers.
timer | to use for difference. |
Adjust timer expiration.
expire | time to subtract in milliseconds. |
Timer& ucommon::Timer::operator-= | ( | time_t | expire | ) |
Adjust timer expiration.
expire | time to subtract in seconds. |
bool ucommon::Timer::operator< | ( | Timer & | timer | ) |
Compare timers if earlier timeout than another timer.
timer | to compare with. |
bool ucommon::Timer::operator<= | ( | Timer & | timer | ) |
Compare timers if earlier than or equal to another timer.
timer | to compare with. |
Set timer expiration.
expire | timer in milliseconds. |
Timer& ucommon::Timer::operator= | ( | time_t | expire | ) |
Set timer expiration.
expire | timer in specified seconds. |
bool ucommon::Timer::operator== | ( | Timer & | timer | ) |
Compare timers if same timeout.
timer | to compare with. |
bool ucommon::Timer::operator> | ( | Timer & | timer | ) |
Compare timers if later timeout than another timer.
timer | to compare with. |
bool ucommon::Timer::operator>= | ( | Timer & | timer | ) |
Compare timers if later than or equal to another timer.
timer | to compare with. |
void ucommon::Timer::set | ( | time_t | expire | ) |
Set the timer to expire.
expire | time in seconds. |
void ucommon::Timer::set | ( | timeout_t | expire | ) |
Set the timer to expire.
expire | time in milliseconds. |
static void ucommon::Timer::sync | ( | Timer & | timer | ) | [static] |
Sleep current thread until the specified timer expires.
timer | to reference for sleep. |
static tick_t ucommon::Timer::ticks | ( | void | ) | [static] |
Get timer ticks since uuid epoch.
bool ucommon::Timer::update | ( | void | ) | [protected] |
Check if timer has been updated since last check.
Reimplemented in ucommon::TimerQueue::event.