NAME

ACE_Timer_List

SYNOPSIS

#include <ace/Timer_List.h>

class ACE_Timer_List : public ACE_Timer_Queue { public: friend class ACE_Timer_List_Iterator; ACE_Timer_List (void); virtual ~ACE_Timer_List (void); virtual int is_empty (void) const; virtual const ACE_Time_Value &earliest_time (void) const; 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 ); virtual int cancel (ACE_Event_Handler *event_handler); virtual int cancel (int timer_id, const void **arg = 0); virtual void dump (void) const; protected: virtual ACE_Timer_Node *alloc_node (void); virtual void free_node (ACE_Timer_Node *); private: int timer_id (void); virtual void reschedule (ACE_Timer_Node *); virtual ACE_Timer_Queue_Iterator &iter (void); ACE_Timer_Node *head_; ACE_Timer_List_Iterator iterator_; int timer_id_; ACE_Timer_List (const ACE_Timer_List &); void operator= (const ACE_Timer_List &); };

DESCRIPTION

This implementation uses a linked list of absolute times. Therefore, in the average case, scheduling and canceling ACE_Event_Handler timers is O(N) (where N is the total number of timers) and expiring timers is O(K) (where K is the total number of timers that are the current time of day).

More clever implementations could use a delta-list, a heap, or timing wheels, etc. For instance, ACE_Timer_Heap is a subclass of ACE_Timer_List that implements a heap-based callout queue. For most applications, the ACE_Timer_Heap will perform substantially faster than the ACE_Timer_List.

Initialization and termination methods.

ACE_Timer_List (void);

virtual ~ACE_Timer_List (void);

virtual int is_empty (void) const;

virtual const ACE_Time_Value &earliest_time (void) const;

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
    );

virtual int cancel (ACE_Event_Handler *event_handler);

virtual int cancel (int timer_id, const void **arg = 0);

virtual void dump (void) const;

Don't allow these operations for now.

ACE_Timer_List (const ACE_Timer_List &);

void operator= (const ACE_Timer_List &);

AUTHOR

Doug Schmidt

TITLE

Provides a simple implementation of timers.

LIBRARY

ace