#include <ace/Timer_Queue.h> class ACE_Timer_Queue {
public:
ACE_Timer_Queue (void);
virtual ~ACE_Timer_Queue (void);
int is_empty (void) const;
const ACE_Time_Value &earliest_time (void) const;
int schedule ( ACE_Event_Handler *event_handler, const void *arg, const ACE_Time_Value &delay, const ACE_Time_Value &interval = ACE_Time_Value::zero );
int cancel (ACE_Event_Handler *event_handler);
int cancel (int timer_id, const void **arg = 0);
int expire (const ACE_Time_Value ¤t_time);
ACE_Time_Value *calculate_timeout (ACE_Time_Value *max);
void dump (void) const;
ACE_ALLOC_HOOK_DECLARE;
private:
ACE_Time_Value timeout_;
void reschedule (ACE_Timer_Node *);
ACE_Timer_Node *head_;
int timer_id_;
ACE_Recursive_Thread_Mutex lock_;
};
ACE_Timer_Queue (void);
virtual ~ACE_Timer_Queue (void);
int is_empty (void) const;
const ACE_Time_Value &earliest_time (void) const;
int schedule (
ACE_Event_Handler *event_handler,
const void *arg,
const ACE_Time_Value &delay,
const ACE_Time_Value &interval = ACE_Time_Value::zero
);
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 handle that uniquely identifies the
event_handler
in an internal list. This timer handle 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.
int cancel (ACE_Event_Handler *event_handler);
event_handlers
that match the address of
event_handler
.
int cancel (int timer_id, const void **arg = 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.
int expire (const ACE_Time_Value ¤t_time);
handle_timeout
method for all Timers whose values are
= cur_time
.
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 dump (void) const;
ACE_ALLOC_HOOK_DECLARE;