UCommon
|
A timer queue for timer events. More...
#include <timers.h>
Data Structures | |
class | event |
A timer event object that lives on a timer queue. More... | |
Public Member Functions | |
timeout_t | expire () |
Process timer queue and find when next event triggers. More... | |
void | operator+= (event &timer) |
Add a timer event to the timer queue. More... | |
void | operator-= (event &timer) |
Remove a timer event from the timer queue. More... | |
TimerQueue () | |
Create an empty timer queue. | |
virtual | ~TimerQueue () |
Destroy queue, does not remove event objects. | |
![]() | |
void | add (OrderedObject *ordered) |
Add an object into the ordered index. More... | |
LinkedObject * | begin (void) const |
Return first object in list for iterators. More... | |
void | copy (const OrderedIndex &source) |
unsigned | count (void) const |
Count of objects this list manages. More... | |
LinkedObject * | end (void) const |
Return last object in list for iterators. More... | |
LinkedObject * | find (unsigned offset) const |
Find a specific member in the ordered list. More... | |
LinkedObject * | get (void) |
Get (pull) object off the list. More... | |
LinkedObject * | getIndexed (unsigned index) const |
Get an indexed member from the ordered index. More... | |
LinkedObject ** | index (void) const |
Return a pointer to the head of the list. More... | |
virtual void | lock_index (void) |
Used to synchronize lists managed by multiple threads. More... | |
LinkedObject * | operator * () const |
Return head object pointer. More... | |
void | operator *= (OrderedObject *object) |
Add object to our list. More... | |
OrderedIndex & | operator= (const OrderedIndex &object) |
Assign ordered index. More... | |
OrderedIndex () | |
Create and initialize an empty index. | |
OrderedIndex (const OrderedIndex &source) | |
void | purge (void) |
Purge the linked list and then set the index to empty. | |
void | reset (void) |
Reset linked list to empty without purging. | |
virtual void | unlock_index (void) |
Used to synchronize lists managed by multiple threads. More... | |
virtual | ~OrderedIndex () |
Destroy index. | |
Protected Member Functions | |
virtual void | modify (void)=0 |
Called in derived class when the queue is being modified. More... | |
virtual void | update (void)=0 |
Called in derived class after the queue has been modified. More... | |
Friends | |
class | event |
Additional Inherited Members | |
![]() | |
OrderedObject * | head |
OrderedObject * | tail |
A timer queue for timer events.
The timer queue is used to hold a linked list of timers that must be processed together. The timer queue processes the timer event list and calls an expired function on events that have expired. The timer queue also determines the wait time until the next timer will expire. When timer events are modified, they can retrigger the queue to re-examine the list to find when the next timer will now expire.
timeout_t ucommon::TimerQueue::expire | ( | ) |
Process timer queue and find when next event triggers.
This function will call the expired methods on expired timers. Normally this function will be called in the context of a timer thread which sleeps for the timeout returned unless it is awoken on an update event.
|
protectedpure virtual |
Called in derived class when the queue is being modified.
This is often used to lock the list.
void ucommon::TimerQueue::operator+= | ( | event & | timer | ) |
Add a timer event to the timer queue.
timer | event to add. |
void ucommon::TimerQueue::operator-= | ( | event & | timer | ) |
Remove a timer event from the timer queue.
timer | event to remove. |
|
protectedpure virtual |
Called in derived class after the queue has been modified.
This often releases a lock that modify set and to wakeup a timer thread to evaluate when the next timer will now expire.