ucc::Timer Class Reference
Timer class to use when scheduling realtime events.
More...
#include <timers.h>
Public Member Functions |
| Timer () |
| Construct an untriggered timer set to the time of creation.
|
| Timer (timeout_t offset) |
| Construct a triggered timer that expires at specified offset.
|
| Timer (time_t offset) |
| Construct a triggered timer that expires at specified offset.
|
bool | isExpired (void) |
| Check if timer expired.
|
bool | isUpdated (void) |
| Check if timer has been updated since last check.
|
void | set (timeout_t expire) |
| Set the timer to expire.
|
void | set (time_t expire) |
| Set the timer to expire.
|
void | set (void) |
| Set (update) the timer with current time.
|
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.
|
bool | operator! () |
| Check if timer has expired.
|
void | operator= (time_t expire) |
| Set timer expiration.
|
void | operator= (timeout_t expire) |
| Set timer expiration.
|
void | operator+= (time_t expire) |
| Adjust timer expiration.
|
void | operator+= (timeout_t expire) |
| Adjust timer expiration.
|
void | operator-= (time_t expire) |
| Adjust timer expiration.
|
void | operator-= (timeout_t expire) |
| Adjust timer expiration.
|
Static Public Member Functions |
static void | sync (Timer &timer) |
| Sleep current thread until the specified timer expires.
|
Static Public Attributes |
static const timeout_t | inf |
| A value to use for infinite time.
|
static const time_t | reset |
| A value to use when resetting.
|
Friends |
class | Conditional |
class | Semaphore |
class | Event |
Detailed Description
Timer class to use when scheduling realtime events.
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.
Constructor & Destructor Documentation
Construct a triggered timer that expires at specified offset.
- Parameters:
-
| offset | to expire in milliseconds. |
ucc::Timer::Timer |
( |
time_t |
offset |
) |
|
Construct a triggered timer that expires at specified offset.
- Parameters:
-
| offset | to expire in seconds. |
Member Function Documentation
Get remaining time until the timer expires.
- Returns:
- 0 if expired or milliseconds still waiting.
Reimplemented in ucc::TimerQueue::event.
bool ucc::Timer::isExpired |
( |
void |
|
) |
|
bool ucc::Timer::isUpdated |
( |
void |
|
) |
|
Check if timer has been updated since last check.
- Returns:
- true if updated.
bool ucc::Timer::operator! |
( |
|
) |
|
Check if timer has expired.
- Returns:
- true if timer still pending.
Get remaining time until timer expires by reference.
- Returns:
- 0 if expired or milliseconds still waiting.
Definition at line 128 of file timers.h.
void ucc::Timer::operator+= |
( |
timeout_t |
expire |
) |
|
Adjust timer expiration.
- Parameters:
-
| expire | time to add in milliseconds. |
void ucc::Timer::operator+= |
( |
time_t |
expire |
) |
|
Adjust timer expiration.
- Parameters:
-
| expire | time to add in seconds. |
void ucc::Timer::operator-= |
( |
timeout_t |
expire |
) |
|
Adjust timer expiration.
- Parameters:
-
| expire | time to subtract in milliseconds. |
void ucc::Timer::operator-= |
( |
time_t |
expire |
) |
|
Adjust timer expiration.
- Parameters:
-
| expire | time to subtract in seconds. |
void ucc::Timer::operator= |
( |
timeout_t |
expire |
) |
|
Set timer expiration.
- Parameters:
-
| expire | timer in milliseconds. |
void ucc::Timer::operator= |
( |
time_t |
expire |
) |
|
Set timer expiration.
- Parameters:
-
| expire | timer in specified seconds. |
void ucc::Timer::set |
( |
time_t |
expire |
) |
|
Set the timer to expire.
- Parameters:
-
Set the timer to expire.
- Parameters:
-
| expire | time in milliseconds. |
static void ucc::Timer::sync |
( |
Timer & |
timer |
) |
[static] |
Sleep current thread until the specified timer expires.
- Parameters:
-
| timer | to reference for sleep. |
The documentation for this class was generated from the following file: