UCommon
Public Member Functions | Protected Member Functions | Friends
ucommon::TimerQueue::event Class Referenceabstract

A timer event object that lives on a timer queue. More...

#include <timers.h>

Inheritance diagram for ucommon::TimerQueue::event:
Inheritance graph
[legend]
Collaboration diagram for ucommon::TimerQueue::event:
Collaboration graph
[legend]

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...
 
TimerQueuelist (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.
 
- Public Member Functions inherited from ucommon::DLinkedObject
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...
 
DLinkedObjectgetNext (void) const
 Get next node in the list when iterating. More...
 
DLinkedObjectgetPrev (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...
 
DLinkedObjectoperator *= (DLinkedObject *object)
 Insert object in list with our object. More...
 
DLinkedObjectoperator+= (DLinkedObject *object)
 Insert object behind our object. More...
 
DLinkedObjectoperator-= (DLinkedObject *object)
 Insert object in front of our object. More...
 
- Public Member Functions inherited from ucommon::OrderedObject
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...
 
OrderedObjectgetNext (void) const
 Get next ordered member when iterating. More...
 
- Public Member Functions inherited from ucommon::LinkedObject
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...
 
LinkedObjectgetNext (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...
 
- Public Member Functions inherited from ucommon::ObjectProtocol
ObjectProtocolcopy (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...
 
- Protected Member Functions inherited from ucommon::Timer
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...
 
Timeroperator+= (time_t expire)
 Adjust timer expiration. More...
 
Timeroperator+= (timeout_t expire)
 Adjust timer expiration. More...
 
timeout_t operator- (const Timer &timer)
 Compute difference between two timers. More...
 
Timeroperator-= (time_t expire)
 Adjust timer expiration. More...
 
Timeroperator-= (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...
 
Timeroperator= (time_t expire)
 Set timer expiration. More...
 
Timeroperator= (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 &copy)
 Construct a timer from a copy of another timer. More...
 
- Protected Member Functions inherited from ucommon::DLinkedObject
 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...
 
DLinkedObjectgetNext (void) const
 Get next node in the list when iterating. More...
 
DLinkedObjectgetPrev (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...
 
DLinkedObjectoperator *= (DLinkedObject *object)
 Insert object in list with our object. More...
 
DLinkedObjectoperator+= (DLinkedObject *object)
 Insert object behind our object. More...
 
DLinkedObjectoperator-= (DLinkedObject *object)
 Insert object in front of our object. More...
 
- Protected Member Functions inherited from ucommon::OrderedObject
 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...
 
OrderedObjectgetNext (void) const
 Get next ordered member when iterating. More...
 
- Protected Member Functions inherited from ucommon::LinkedObject
 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...
 
LinkedObjectgetNext (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...
 
- Protected Member Functions inherited from ucommon::ObjectProtocol
ObjectProtocolcopy (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 Public Member Functions inherited from ucommon::LinkedObject
static unsigned count (const LinkedObject *root)
 Count the number of linked objects in a list. More...
 
static LinkedObjectgetIndexed (LinkedObject *root, unsigned index)
 Get member by index. More...
 
static void purge (LinkedObject *root)
 Release all objects from a list. More...
 
- Protected Types inherited from ucommon::Timer
typedef uint64_t tick_t
 
- Static Protected Member Functions inherited from ucommon::Timer
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 Protected Member Functions inherited from ucommon::LinkedObject
static unsigned count (const LinkedObject *root)
 Count the number of linked objects in a list. More...
 
static LinkedObjectgetIndexed (LinkedObject *root, unsigned index)
 Get member by index. More...
 
static void purge (LinkedObject *root)
 Release all objects from a list. More...
 
- Protected Attributes inherited from ucommon::DLinkedObject
DLinkedObjectPrev
 
OrderedIndexRoot
 
- Protected Attributes inherited from ucommon::LinkedObject
LinkedObjectNext
 
- Static Protected Attributes inherited from ucommon::Timer
static const timeout_t inf = ((timeout_t)(-1))
 
static const time_t reset = ((time_t)(0))
 

Detailed Description

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.

Author
David Sugar dyfet.nosp@m.@gnu.nosp@m.telep.nosp@m.hony.nosp@m..org

Definition at line 282 of file timers.h.

Constructor & Destructor Documentation

◆ event() [1/2]

ucommon::TimerQueue::event::event ( timeout_t  expire)
protected

Construct a timer event object and initially arm.

Parameters
expiretimer in specified milliseconds.

◆ event() [2/2]

ucommon::TimerQueue::event::event ( TimerQueue queue,
timeout_t  expire 
)
protected

Construct an armed timer event object and attach to queue.

Parameters
queueto add event to.
expiretimer in specified milliseconds.

Member Function Documentation

◆ arm()

void ucommon::TimerQueue::event::arm ( timeout_t  timeout)

Arm event to trigger at specified timeout.

Parameters
timeoutto expire and trigger.

◆ attach()

void ucommon::TimerQueue::event::attach ( TimerQueue queue)

Attach event to a timer queue.

Detaches from previous list if already attached elsewhere.

Parameters
queueto attach to.

◆ get()

timeout_t ucommon::TimerQueue::event::get ( void  ) const
inline

Time remaining until expired.

Returns
milliseconds until timer expires.

Definition at line 348 of file timers.h.

Here is the call graph for this function:

◆ list()

TimerQueue* ucommon::TimerQueue::event::list ( void  ) const
inline

Get the timer queue we are attached to.

Returns
timer queue or NULL if not attached.

Definition at line 365 of file timers.h.

◆ timeout()

virtual timeout_t ucommon::TimerQueue::event::timeout ( void  )
protectedvirtual

Expected next timeout for the timer.

This may be overriden for strategy purposes when evaluted by timer queue's expire.

Returns
milliseconds until timer next triggers.

The documentation for this class was generated from the following file: