NAME

ACE_Timer_List_T

SYNOPSIS

#include <ace/Timer_List_T.h>

template<class TYPE, class FUNCTOR, class ACE_LOCK> class ACE_Timer_List_T : public ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK> { public: typedef ACE_Timer_List_Iterator_T<TYPE, FUNCTOR, ACE_LOCK> LIST_ITERATOR; friend class ACE_Timer_List_Iterator_T<TYPE, FUNCTOR, ACE_LOCK>; typedef ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK> INHERITED; ACE_Timer_List_T ( FUNCTOR *upcall_functor = 0, ACE_Free_List<ACE_Timer_Node_T <TYPE> > *freelist = 0 ); virtual ~ACE_Timer_List_T (void); virtual int is_empty (void) const; virtual const ACE_Time_Value &earliest_time (void) const; virtual long schedule ( const TYPE &type, const void *act, const ACE_Time_Value &delay, const ACE_Time_Value &interval = ACE_Time_Value::zero ); virtual int cancel ( const TYPE &type, int dont_call_handle_close = 1 ); virtual int cancel ( long timer_id, const void **act = 0, int dont_call_handle_close = 1 ); virtual ACE_Timer_Queue_Iterator_T<TYPE, FUNCTOR, ACE_LOCK> &iter ( void ); virtual ACE_Timer_Node_T<TYPE> *remove_first (void); virtual void dump (void) const; virtual void reschedule (ACE_Timer_Node_T<TYPE> *); virtual ACE_Timer_Node_T<TYPE> *get_first (void); protected: /* virtual ACE_Timer_Node_T<TYPE> *alloc_node (void); virtual void free_node (ACE_Timer_Node_T<TYPE> *); private: ACE_Timer_Node_T<TYPE> *head_; LIST_ITERATOR *iterator_; long timer_id_; inline ACE_UNIMPLEMENTED_FUNC ( ACE_Timer_List_T (const ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK> &) ); };

DESCRIPTION

This implementation uses a linked list of absolute times. Therefore, in the average case, scheduling and canceling 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_T (
    FUNCTOR *upcall_functor = 0,
    ACE_Free_List<ACE_Timer_Node_T <TYPE> > *freelist = 0
    );

virtual ~ACE_Timer_List_T (void);

virtual int is_empty (void) const;

virtual const ACE_Time_Value &earliest_time (void) const;

virtual long schedule (
    const TYPE &type,
    const void *act,
    const ACE_Time_Value &delay,
    const ACE_Time_Value &interval = ACE_Time_Value::zero
    );

virtual int cancel (const TYPE &type, int dont_call_handle_close = 1);

virtual int cancel (
    long timer_id,
    const void **act = 0,
    int dont_call_handle_close = 1
    );

virtual ACE_Timer_Queue_Iterator_T<TYPE, FUNCTOR, ACE_LOCK> &iter (
    void
    );

virtual ACE_Timer_Node_T<TYPE> *remove_first (void);

virtual void dump (void) const;

virtual void reschedule (ACE_Timer_Node_T<TYPE> *);

virtual ACE_Timer_Node_T<TYPE> *get_first (void);

Don't allow these operations for now.

inline ACE_UNIMPLEMENTED_FUNC (
    ACE_Timer_List_T (const ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK> &)
    );

AUTHOR

Doug Schmidt

TITLE

Provides a simple implementation of timers.

LIBRARY

ace