28 #ifndef _UCOMMON_TIMERS_H_ 29 #define _UCOMMON_TIMERS_H_ 31 #ifndef _UCOMMON_LINKED_H_ 53 friend class Conditional;
54 friend class Semaphore;
57 #if _POSIX_TIMERS > 0 && defined(POSIX_TIMERS) 60 #undef POSIX_TIMERS // make sure not used if no support 77 bool is_active(
void)
const;
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;
98 Timer(timeout_t offset);
104 Timer(time_t offset);
110 Timer(
const Timer&
copy);
116 void set(timeout_t expire);
122 void set(time_t expire);
138 timeout_t
get(void)
const;
144 inline timeout_t operator*()
const {
152 bool operator!()
const;
158 operator bool()
const;
164 Timer& operator=(time_t expire);
170 Timer& operator=(timeout_t expire);
176 Timer& operator+=(time_t expire);
182 Timer& operator+=(timeout_t expire);
188 Timer& operator-=(time_t expire);
194 Timer& operator-=(timeout_t expire);
201 timeout_t operator-(
const Timer& timer);
208 bool operator==(
const Timer& timer)
const;
215 bool operator!=(
const Timer& timer)
const;
222 bool operator<(
const Timer& timer)
const;
229 bool operator<=(
const Timer& timer)
const;
236 bool operator>(
const Timer& timer)
const;
243 bool operator>=(
const Timer& timer)
const;
249 static void sync(Timer &timer);
255 static tick_t ticks(
void);
268 class __EXPORT TimerQueue :
public OrderedIndex
271 __DELETE_COPY(TimerQueue);
282 class __EXPORT event :
protected Timer,
public DLinkedObject
285 __DELETE_DEFAULTS(event);
288 friend class TimerQueue;
294 event(timeout_t expire);
301 event(TimerQueue *queue, timeout_t expire);
306 virtual void expired(
void) = 0;
313 virtual timeout_t timeout(
void);
326 void attach(TimerQueue *queue);
337 void arm(timeout_t timeout);
348 inline timeout_t
get(void)
const {
352 inline timeout_t operator*()
const {
365 inline TimerQueue *list(
void)
const {
366 return static_cast<TimerQueue*
>(Root);
377 virtual void modify(
void) = 0;
384 virtual void update(
void) = 0;
395 virtual ~TimerQueue();
401 void operator+=(event &timer);
407 void operator-=(event &timer);
422 typedef TimerQueue::event
TQEvent;
Timer timer_t
A convenience type for timers.
Common namespace for all ucommon objects.
T copy(const T &src)
Convenience function to copy objects.
Linked objects, lists, templates, and containers.
class __attribute__((visibility("default"))) TimerQueue typedef TimerQueue::event TQEvent
A timer queue for timer events.