UCommon
|
A timer event object that lives on a timer queue. More...
#include <timers.h>
Public Member Functions | |
void | arm (timeout_t timeout) |
Arm event to trigger at specified timeout. More... | |
void | attach (TimerQueue *queue) |
Attach event to a timer queue. More... | |
void | detach (void) |
Detach event from a timer queue. | |
void | disarm (void) |
Disarm event. | |
timeout_t | get (void) const |
Time remaining until expired. More... | |
TimerQueue * | list (void) const |
Get the timer queue we are attached to. More... | |
timeout_t | operator * () const |
void | update (void) |
Notify timer queue that the timer has been updated. | |
virtual | ~event () |
Detaches from queue when destroyed. | |
![]() | |
void | delist (void) |
Remove our object from the list it is currently part of. | |
void | enlist (OrderedIndex *index) |
Attach our object to a linked list. More... | |
void | enlistHead (OrderedIndex *index) |
Attach our object to the start of a linked list though an ordered index. More... | |
void | enlistTail (OrderedIndex *index) |
Attach our object to the end of a linked list though an ordered index. More... | |
DLinkedObject * | getNext (void) const |
Get next node in the list when iterating. More... | |
DLinkedObject * | getPrev (void) const |
Get previous node in the list for reverse iteration. More... | |
virtual void | insert (DLinkedObject *object) |
Insert object, method in derived object. More... | |
void | insertHead (DLinkedObject *object) |
Insert object in front of our object. More... | |
void | insertTail (DLinkedObject *object) |
Insert object behind our object. More... | |
bool | is_head (void) const |
Test if we are at the head of a list. More... | |
bool | is_tail (void) const |
Test if we are at the end of a list. More... | |
DLinkedObject & | operator *= (DLinkedObject *object) |
Insert object in list with our object. More... | |
DLinkedObject & | operator+= (DLinkedObject *object) |
Insert object behind our object. More... | |
DLinkedObject & | operator-= (DLinkedObject *object) |
Insert object in front of our object. More... | |
![]() | |
void | delist (OrderedIndex *index) |
Remove our ordered object from an existing index. More... | |
void | enlistHead (OrderedIndex *index) |
List our ordered object at start of a linked list on an index. More... | |
void | enlistTail (OrderedIndex *index) |
List our ordered object at end of a linked list on an index. More... | |
OrderedObject * | getNext (void) const |
Get next ordered member when iterating. More... | |
![]() | |
void | delist (LinkedObject **root) |
Locate and remove ourselves from a list of objects. More... | |
void | enlist (LinkedObject **root) |
Add our object to an existing linked list through a pointer. More... | |
LinkedObject * | getNext (void) const |
Get next effective object when iterating. More... | |
bool | is_member (LinkedObject *list) const |
Search to see if we are a member of a specific list. More... | |
virtual void | release (void) |
Release list, mark as no longer linked. More... | |
virtual void | retain (void) |
Retain by marking as self referenced list. More... | |
![]() | |
ObjectProtocol * | copy (void) |
Retain (increase retention of) object when copying. | |
void | operator++ (void) |
Increase retention operator. | |
void | operator-- (void) |
Decrease retention operator. | |
virtual | ~ObjectProtocol () |
Required virtual destructor. | |
Protected Member Functions | |
event (timeout_t expire) | |
Construct a timer event object and initially arm. More... | |
event (TimerQueue *queue, timeout_t expire) | |
Construct an armed timer event object and attach to queue. More... | |
virtual void | expired (void)=0 |
Event method to call in derived class when timer expires. | |
virtual timeout_t | timeout (void) |
Expected next timeout for the timer. More... | |
![]() | |
bool | is_active (void) const |
Check if timer active. More... | |
bool | update (void) |
Check if timer has been updated since last check. More... | |
void | clear (void) |
Clear pending timer, has no value. | |
timeout_t | get (void) const |
Get remaining time until the timer expires. More... | |
timeout_t | operator * () const |
Get remaining time until timer expires by reference. More... | |
operator bool () const | |
Check if timer expired for is() expression. More... | |
bool | operator! () const |
Check if timer has expired. More... | |
bool | operator!= (const Timer &timer) const |
Compare timers if not same timeout. More... | |
Timer & | operator+= (time_t expire) |
Adjust timer expiration. More... | |
Timer & | operator+= (timeout_t expire) |
Adjust timer expiration. More... | |
timeout_t | operator- (const Timer &timer) |
Compute difference between two timers. More... | |
Timer & | operator-= (time_t expire) |
Adjust timer expiration. More... | |
Timer & | operator-= (timeout_t expire) |
Adjust timer expiration. More... | |
bool | operator< (const Timer &timer) const |
Compare timers if earlier timeout than another timer. More... | |
bool | operator<= (const Timer &timer) const |
Compare timers if earlier than or equal to another timer. More... | |
Timer & | operator= (time_t expire) |
Set timer expiration. More... | |
Timer & | operator= (timeout_t expire) |
Set timer expiration. More... | |
bool | operator== (const Timer &timer) const |
Compare timers if same timeout. More... | |
bool | operator> (const Timer &timer) const |
Compare timers if later timeout than another timer. More... | |
bool | operator>= (const Timer &timer) const |
Compare timers if later than or equal to another timer. More... | |
void | set (timeout_t expire) |
Set the timer to expire. More... | |
void | set (time_t expire) |
Set the timer to expire. More... | |
void | set (void) |
Set (update) the timer with current time. | |
Timer () | |
Construct an untriggered timer set to the time of creation. | |
Timer (timeout_t offset) | |
Construct a triggered timer that expires at specified offset. More... | |
Timer (time_t offset) | |
Construct a triggered timer that expires at specified offset. More... | |
Timer (const Timer ©) | |
Construct a timer from a copy of another timer. More... | |
![]() | |
DLinkedObject (OrderedIndex *index) | |
Construct and add our object to an existing double linked list at end. More... | |
DLinkedObject () | |
Construct an unlinked object. | |
DLinkedObject (const DLinkedObject &from) | |
virtual | ~DLinkedObject () |
Delete linked list object. More... | |
void | delist (void) |
Remove our object from the list it is currently part of. | |
void | enlist (OrderedIndex *index) |
Attach our object to a linked list. More... | |
void | enlistHead (OrderedIndex *index) |
Attach our object to the start of a linked list though an ordered index. More... | |
void | enlistTail (OrderedIndex *index) |
Attach our object to the end of a linked list though an ordered index. More... | |
DLinkedObject * | getNext (void) const |
Get next node in the list when iterating. More... | |
DLinkedObject * | getPrev (void) const |
Get previous node in the list for reverse iteration. More... | |
virtual void | insert (DLinkedObject *object) |
Insert object, method in derived object. More... | |
void | insertHead (DLinkedObject *object) |
Insert object in front of our object. More... | |
void | insertTail (DLinkedObject *object) |
Insert object behind our object. More... | |
bool | is_head (void) const |
Test if we are at the head of a list. More... | |
bool | is_tail (void) const |
Test if we are at the end of a list. More... | |
DLinkedObject & | operator *= (DLinkedObject *object) |
Insert object in list with our object. More... | |
DLinkedObject & | operator+= (DLinkedObject *object) |
Insert object behind our object. More... | |
DLinkedObject & | operator-= (DLinkedObject *object) |
Insert object in front of our object. More... | |
![]() | |
OrderedObject (OrderedIndex *index) | |
Construct an ordered object aot end of a an index. More... | |
OrderedObject () | |
Construct an ordered object unattached. | |
OrderedObject (const OrderedObject &from) | |
void | delist (OrderedIndex *index) |
Remove our ordered object from an existing index. More... | |
void | enlistHead (OrderedIndex *index) |
List our ordered object at start of a linked list on an index. More... | |
void | enlistTail (OrderedIndex *index) |
List our ordered object at end of a linked list on an index. More... | |
OrderedObject * | getNext (void) const |
Get next ordered member when iterating. More... | |
![]() | |
LinkedObject (LinkedObject **root) | |
Construct base class attached to a chain of objects. More... | |
LinkedObject () | |
Construct base class unattached to anyone. More... | |
LinkedObject (const LinkedObject &from) | |
void | delist (LinkedObject **root) |
Locate and remove ourselves from a list of objects. More... | |
void | enlist (LinkedObject **root) |
Add our object to an existing linked list through a pointer. More... | |
LinkedObject * | getNext (void) const |
Get next effective object when iterating. More... | |
bool | is_member (LinkedObject *list) const |
Search to see if we are a member of a specific list. More... | |
virtual void | release (void) |
Release list, mark as no longer linked. More... | |
virtual void | retain (void) |
Retain by marking as self referenced list. More... | |
![]() | |
ObjectProtocol * | copy (void) |
Retain (increase retention of) object when copying. | |
void | operator++ (void) |
Increase retention operator. | |
void | operator-- (void) |
Decrease retention operator. | |
virtual | ~ObjectProtocol () |
Required virtual destructor. | |
Friends | |
class | TimerQueue |
Additional Inherited Members | |
![]() | |
static unsigned | count (const LinkedObject *root) |
Count the number of linked objects in a list. More... | |
static LinkedObject * | getIndexed (LinkedObject *root, unsigned index) |
Get member by index. More... | |
static void | purge (LinkedObject *root) |
Release all objects from a list. More... | |
![]() | |
typedef uint64_t | tick_t |
![]() | |
static void | sync (Timer &timer) |
Sleep current thread until the specified timer expires. More... | |
static tick_t | ticks (void) |
Get timer ticks since uuid epoch. More... | |
![]() | |
static unsigned | count (const LinkedObject *root) |
Count the number of linked objects in a list. More... | |
static LinkedObject * | getIndexed (LinkedObject *root, unsigned index) |
Get member by index. More... | |
static void | purge (LinkedObject *root) |
Release all objects from a list. More... | |
![]() | |
DLinkedObject * | Prev |
OrderedIndex * | Root |
![]() | |
LinkedObject * | Next |
![]() | |
static const timeout_t | inf = ((timeout_t)(-1)) |
static const time_t | reset = ((time_t)(0)) |
A timer event object that lives on a timer queue.
Timer events are triggered through the timer queue's expire method. Timer events also modify the queue when they are changed, particularly to force re-evaluation of the expiration period. This class is not used by itself but rather as a base class for a timer event object.
|
protected |
Construct a timer event object and initially arm.
expire | timer in specified milliseconds. |
|
protected |
Construct an armed timer event object and attach to queue.
queue | to add event to. |
expire | timer in specified milliseconds. |
void ucommon::TimerQueue::event::arm | ( | timeout_t | timeout | ) |
Arm event to trigger at specified timeout.
timeout | to expire and trigger. |
void ucommon::TimerQueue::event::attach | ( | TimerQueue * | queue | ) |
Attach event to a timer queue.
Detaches from previous list if already attached elsewhere.
queue | to attach to. |
|
inline |
|
inline |
|
protectedvirtual |
Expected next timeout for the timer.
This may be overriden for strategy purposes when evaluted by timer queue's expire.