28#ifndef _UCOMMON_TIMERS_H_
29#define _UCOMMON_TIMERS_H_
31#ifndef _UCOMMON_LINKED_H_
57#if _POSIX_TIMERS > 0 && defined(POSIX_TIMERS)
80 static const timeout_t inf = ((timeout_t)(-1));
81 static const time_t reset = ((time_t)(0));
84 typedef unsigned __int64 tick_t;
86 typedef uint64_t tick_t;
116 void set(timeout_t expire);
138 timeout_t
get(
void)
const;
158 operator bool()
const;
285 __DELETE_DEFAULTS(
event);
337 void arm(timeout_t timeout);
348 inline timeout_t
get(
void)
const {
352 inline timeout_t operator*()
const {
Linked objects, lists, templates, and containers.
Common namespace for all ucommon objects.
TimerQueue::event TQEvent
A convenience type for timer queue timer events.
Timer timer_t
A convenience type for timers.
The conditional is a common base for other thread synchronizing classes.
A portable counting semaphore class.
An index container for maintaining an ordered list of objects.
A double linked list object.
Timer class to use when scheduling realtime events.
bool operator<(const Timer &timer) const
Compare timers if earlier timeout than another timer.
void set(timeout_t expire)
Set the timer to expire.
void set(void)
Set (update) the timer with current time.
bool operator<=(const Timer &timer) const
Compare timers if earlier than or equal to another timer.
Timer(const Timer ©)
Construct a timer from a copy of another timer.
bool is_active(void) const
Check if timer active.
Timer(timeout_t offset)
Construct a triggered timer that expires at specified offset.
bool operator>(const Timer &timer) const
Compare timers if later timeout than another timer.
timeout_t operator-(const Timer &timer)
Compute difference between two timers.
timeout_t get(void) const
Get remaining time until the timer expires.
Timer()
Construct an untriggered timer set to the time of creation.
static tick_t ticks(void)
Get timer ticks since uuid epoch.
Timer & operator+=(time_t expire)
Adjust timer expiration.
bool operator!=(const Timer &timer) const
Compare timers if not same timeout.
void set(time_t expire)
Set the timer to expire.
bool operator==(const Timer &timer) const
Compare timers if same timeout.
timeout_t operator*() const
Get remaining time until timer expires by reference.
bool update(void)
Check if timer has been updated since last check.
Timer & operator=(timeout_t expire)
Set timer expiration.
bool operator!() const
Check if timer has expired.
Timer & operator-=(time_t expire)
Adjust timer expiration.
bool operator>=(const Timer &timer) const
Compare timers if later than or equal to another timer.
Timer(time_t offset)
Construct a triggered timer that expires at specified offset.
Timer & operator=(time_t expire)
Set timer expiration.
Timer & operator-=(timeout_t expire)
Adjust timer expiration.
Timer & operator+=(timeout_t expire)
Adjust timer expiration.
void clear(void)
Clear pending timer, has no value.
static void sync(Timer &timer)
Sleep current thread until the specified timer expires.
A timer queue for timer events.
virtual void modify(void)=0
Called in derived class when the queue is being modified.
TimerQueue()
Create an empty timer queue.
timeout_t expire()
Process timer queue and find when next event triggers.
void operator+=(event &timer)
Add a timer event to the timer queue.
virtual void update(void)=0
Called in derived class after the queue has been modified.
void operator-=(event &timer)
Remove a timer event from the timer queue.
virtual ~TimerQueue()
Destroy queue, does not remove event objects.
A timer event object that lives on a timer queue.
virtual ~event()
Detaches from queue when destroyed.
void arm(timeout_t timeout)
Arm event to trigger at specified timeout.
virtual void expired(void)=0
Event method to call in derived class when timer expires.
void detach(void)
Detach event from a timer queue.
void update(void)
Notify timer queue that the timer has been updated.
void disarm(void)
Disarm event.
event(timeout_t expire)
Construct a timer event object and initially arm.
void attach(TimerQueue *queue)
Attach event to a timer queue.
timeout_t get(void) const
Time remaining until expired.
TimerQueue * list(void) const
Get the timer queue we are attached to.
event(TimerQueue *queue, timeout_t expire)
Construct an armed timer event object and attach to queue.
virtual timeout_t timeout(void)
Expected next timeout for the timer.