#include <ace/Timer_Queue.h>
class ACE_Timer_Queue {
public:ACE_Timer_Queue (void);virtual ~ACE_Timer_Queue (void);virtual int is_empty (void) const = 0;virtual const ACE_Time_Value &earliest_time (void) const = 0;virtual int schedule ( ACE_Event_Handler *event_handler, const void *arg, const ACE_Time_Value &delay, const ACE_Time_Value &interval = ACE_Time_Value::zero ) = 0;virtual int cancel (ACE_Event_Handler *event_handler) = 0;virtual int cancel (int timer_id, const void **arg = 0) = 0;virtual int expire (const ACE_Time_Value ¤t_time);virtual int expire (void);virtual ACE_Time_Value gettimeofday (void);void gettimeofday (ACE_Time_Value (*gettimeofday)(void));virtual ACE_Time_Value *calculate_timeout (ACE_Time_Value *max);void timer_skew (const ACE_Time_Value &skew);const ACE_Time_Value &timer_skew (void) const;virtual void dump (void) const;ACE_ALLOC_HOOK_DECLARE;protected:virtual void reschedule (ACE_Timer_Node *) = 0;virtual ACE_Timer_Queue_Iterator &iter (void) = 0;virtual ACE_Timer_Node *alloc_node (void) = 0;virtual void free_node (ACE_Timer_Node *) = 0;ACE_Recursive_Thread_Mutex lock_;ACE_Time_Value (*gettimeofday_)(void);private:ACE_Time_Value timeout_;ACE_Time_Value timer_skew_;ACE_Timer_Queue (const ACE_Timer_Queue &);void operator= (const ACE_Timer_Queue &);};
ACE_Timer_List
and ACE_Timer_Heap.
ACE_Timer_Queue (void);
virtual ~ACE_Timer_Queue (void);
virtual int is_empty (void) const = 0;
virtual const ACE_Time_Value &earliest_time (void) const = 0;
virtual int schedule (
ACE_Event_Handler *event_handler,
const void *arg,
const ACE_Time_Value &delay,
const ACE_Time_Value &interval = ACE_Time_Value::zero
) = 0;
event_handler that will expire after delay amount
of time. If it expires then arg is passed in as the value to
the event_handler's handle_timeout callback method. If
interval is != to ACE_Time_Value::zero then it is used to
reschedule the event_handler automatically. This method
returns a timer_id that uniquely identifies the event_handler
in an internal list. This timer_id can be used to cancel an
event_handler before it expires. The cancellation ensures that
timer_ids are unique up to values of greater than 2 billion
timers. As long as timers don't stay around longer than this
there should be no problems with accidentally deleting the wrong
timer. Returns -1 on failure (which is guaranteed never to be a
valid timer_id).
virtual int cancel (ACE_Event_Handler *event_handler) = 0;
event_handlers that match the address of
event_handler. Returns number of handler's cancelled.
virtual int cancel (int timer_id, const void **arg = 0) = 0;
ACE_Event_Handler that matches the timer_id
value (which was returned from the schedule method). If arg is
non-NULL then it will be set to point to the ``magic cookie''
argument passed in when the Event_Handler was registered. This
makes it possible to free up the memory and avoid memory leaks.
Returns 1 if cancellation succeeded and 0 if the timer_id
wasn't found.
virtual int expire (const ACE_Time_Value ¤t_time);
handle_timeout method for all Timers whose values are
= cur_time. This does not account for timer_skew. Returns
the number of Event_Handlers for which handle_timeout was
called.
virtual int expire (void);
handle_timeout method for all Timers whose values are
= ACE_OS::gettimeofday. Also accounts for timer_skew.
Returns the number of Event_Handlers for which handle_timeout
was called.
virtual ACE_Time_Value gettimeofday (void);
void gettimeofday (ACE_Time_Value (*gettimeofday)(void));
virtual ACE_Time_Value *calculate_timeout (ACE_Time_Value *max);
max if there are
no pending timers or if all pending timers are longer than max.
void timer_skew (const ACE_Time_Value &skew);
const ACE_Time_Value &timer_skew (void) const;
virtual void dump (void) const;
ACE_ALLOC_HOOK_DECLARE;
ACE_Timer_Queue (const ACE_Timer_Queue &);
void operator= (const ACE_Timer_Queue &);