ACE 8.0.0
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes | List of all members
ACE_Timer_Queue_T< TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY > Class Template Referenceabstract

Provides an interface to timers. More...

#include <Timer_Queue_T.h>

Inheritance diagram for ACE_Timer_Queue_T< TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY >:
Inheritance graph
[legend]
Collaboration diagram for ACE_Timer_Queue_T< TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY >:
Collaboration graph
[legend]

Public Types

typedef TIME_POLICY time_policy_t
 Type of time policy.
 
- Public Types inherited from ACE_Abstract_Timer_Queue< TYPE >
typedef ACE_Timer_Queue_Iterator_T< TYPE > ITERATOR
 Type of Iterator.
 

Public Member Functions

 ACE_Timer_Queue_T (FUNCTOR *upcall_functor=0, ACE_Free_List< ACE_Timer_Node_T< TYPE > > *freelist=0, TIME_POLICY const &time_policy=TIME_POLICY())
 
virtual ~ACE_Timer_Queue_T ()
 
virtual long schedule (const TYPE &type, const void *act, const ACE_Time_Value &future_time, const ACE_Time_Value &interval=ACE_Time_Value::zero)
 
virtual int expire (const ACE_Time_Value &current_time)
 
virtual int expire ()
 
virtual int expire_single (ACE_Command_Base &pre_dispatch_command)
 
virtual int dispatch_info (const ACE_Time_Value &current_time, ACE_Timer_Node_Dispatch_Info_T< TYPE > &info)
 
virtual ACE_Time_Value gettimeofday ()
 
virtual void gettimeofday (ACE_Time_Value(*gettimeofday)())
 
ACE_Time_Value gettimeofday_static ()
 
void set_time_policy (TIME_POLICY const &time_policy)
 
virtual ACE_Time_Valuecalculate_timeout (ACE_Time_Value *max)
 
virtual ACE_Time_Valuecalculate_timeout (ACE_Time_Value *max, ACE_Time_Value *the_timeout)
 
virtual ACE_Time_Value current_time ()
 
void timer_skew (const ACE_Time_Value &skew)
 Set the timer skew for the Timer_Queue.
 
const ACE_Time_Valuetimer_skew () const
 Get the timer skew for the Timer_Queue.
 
ACE_LOCK & mutex ()
 Synchronization variable used by the queue.
 
virtual void dump () const
 Dump the state of a object.
 
virtual void return_node (ACE_Timer_Node_T< TYPE > *)
 
void preinvoke (ACE_Timer_Node_Dispatch_Info_T< TYPE > &info, const ACE_Time_Value &cur_time, const void *&upcall_act)
 This method will call the preinvoke() on <functor>.
 
void upcall (ACE_Timer_Node_Dispatch_Info_T< TYPE > &info, const ACE_Time_Value &cur_time)
 This method will call the timeout() on <functor>.
 
void postinvoke (ACE_Timer_Node_Dispatch_Info_T< TYPE > &info, const ACE_Time_Value &cur_time, const void *upcall_act)
 This method will call the postinvoke() on <functor>.
 
- Public Member Functions inherited from ACE_Timer_Queue_Upcall_Base< TYPE, FUNCTOR >
 ACE_Timer_Queue_Upcall_Base (FUNCTOR *upcall_functor=nullptr)
 
virtual ~ACE_Timer_Queue_Upcall_Base ()
 Destructor.
 
FUNCTORupcall_functor ()
 Accessor to the upcall functor.
 
- Public Member Functions inherited from ACE_Abstract_Timer_Queue< TYPE >
virtual ~ACE_Abstract_Timer_Queue ()=0
 Destructor.
 
virtual bool is_empty () const =0
 True if queue is empty, else false.
 
virtual const ACE_Time_Valueearliest_time () const =0
 
virtual int reset_interval (long timer_id, const ACE_Time_Value &interval)=0
 
virtual int cancel (const TYPE &type, int dont_call_handle_close=1)=0
 
virtual int cancel (long timer_id, const void **act=0, int dont_call_handle_close=1)=0
 
virtual int close ()=0
 
virtual ITERATORiter ()=0
 Returns a pointer to this ACE_Timer_Queue's iterator.
 
virtual ACE_Timer_Node_T< TYPE > * remove_first ()=0
 Removes the earliest node from the queue and returns it.
 
virtual ACE_Timer_Node_T< TYPE > * get_first ()=0
 Reads the earliest node from the queue and returns it.
 

Protected Member Functions

virtual long schedule_i (const TYPE &type, const void *act, const ACE_Time_Value &future_time, const ACE_Time_Value &interval)=0
 Schedule a timer.
 
virtual void reschedule (ACE_Timer_Node_T< TYPE > *)=0
 Reschedule an "interval" ACE_Timer_Node.
 
virtual ACE_Timer_Node_T< TYPE > * alloc_node ()
 Factory method that allocates a new node.
 
virtual void free_node (ACE_Timer_Node_T< TYPE > *)
 Factory method that frees a previously allocated node.
 
virtual int dispatch_info_i (const ACE_Time_Value &current_time, ACE_Timer_Node_Dispatch_Info_T< TYPE > &info)
 Non-locking version of dispatch_info ()
 
void recompute_next_abs_interval_time (ACE_Timer_Node_T< TYPE > *expired, const ACE_Time_Value &cur_time)
 Recompute when the next time is that this interval timer should fire.
 

Protected Attributes

ACE_LOCK mutex_
 
ACE_Free_List< ACE_Timer_Node_T< TYPE > > * free_list_
 Class that implements a free list.
 
TIME_POLICY time_policy_
 The policy to return the current time of day.
 
bool const delete_free_list_
 Flag to delete only if the class created the <free_list_>
 
- Protected Attributes inherited from ACE_Timer_Queue_Upcall_Base< TYPE, FUNCTOR >
FUNCTORupcall_functor_
 Upcall functor.
 
bool const delete_upcall_functor_
 To delete or not to delete is the question?
 

Private Attributes

ACE_Time_Value timeout_
 Returned by <calculate_timeout>.
 
ACE_Time_Value timer_skew_
 Adjusts for timer skew in various clocks.
 

Detailed Description

template<class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY = ACE_Default_Time_Policy>
class ACE_Timer_Queue_T< TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY >

Provides an interface to timers.

This is an abstract base class that provides hook for implementing specialized policies such as ACE_Timer_List and ACE_Timer_Heap.

Member Typedef Documentation

◆ time_policy_t

template<class TYPE , class FUNCTOR , class ACE_LOCK , typename TIME_POLICY = ACE_Default_Time_Policy>
typedef TIME_POLICY ACE_Timer_Queue_T< TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY >::time_policy_t

Type of time policy.

Constructor & Destructor Documentation

◆ ACE_Timer_Queue_T()

template<class TYPE , class FUNCTOR , class ACE_LOCK , typename TIME_POLICY >
ACE_Timer_Queue_T< TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY >::ACE_Timer_Queue_T ( FUNCTOR * upcall_functor = 0,
ACE_Free_List< ACE_Timer_Node_T< TYPE > > * freelist = 0,
TIME_POLICY const & time_policy = TIME_POLICY() )

Default constructor. upcall_functor is the instance of the FUNCTOR to be used by the queue. If upcall_functor is 0, Timer Queue will create a default FUNCTOR. freelist the freelist of timer nodes. If 0, then a default freelist will be created.

◆ ~ACE_Timer_Queue_T()

template<class TYPE , class FUNCTOR , class ACE_LOCK , typename TIME_POLICY >
ACE_Timer_Queue_T< TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY >::~ACE_Timer_Queue_T ( )
virtual

Destructor - make virtual for proper destruction of inherited classes.

Member Function Documentation

◆ alloc_node()

template<class TYPE , class FUNCTOR , class ACE_LOCK , typename TIME_POLICY >
ACE_Timer_Node_T< TYPE > * ACE_Timer_Queue_T< TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY >::alloc_node ( )
protectedvirtual

Factory method that allocates a new node.

Reimplemented in ACE_Timer_Heap_T< TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY >.

◆ calculate_timeout() [1/2]

template<class TYPE , class FUNCTOR , class ACE_LOCK , typename TIME_POLICY >
ACE_Time_Value * ACE_Timer_Queue_T< TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY >::calculate_timeout ( ACE_Time_Value * max)
virtual

Determine the next event to timeout. Returns max if there are no pending timers or if all pending timers are longer than max. This method acquires a lock internally since it modifies internal state. Implement calculate_timeout() using the right locking policy

Implements ACE_Abstract_Timer_Queue< TYPE >.

◆ calculate_timeout() [2/2]

template<class TYPE , class FUNCTOR , class ACE_LOCK , typename TIME_POLICY >
ACE_Time_Value * ACE_Timer_Queue_T< TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY >::calculate_timeout ( ACE_Time_Value * max,
ACE_Time_Value * the_timeout )
virtual

Determine the next event to timeout. Returns max if there are no pending timers or if all pending timers are longer than max. the_timeout should be a pointer to storage for the timeout value, and this value is also returned. This method does not acquire a lock internally since it doesn't modify internal state. If you need to call this method when the queue is being modified concurrently, however, you should make sure to acquire the <mutex()> externally before making the call.

Implements ACE_Abstract_Timer_Queue< TYPE >.

◆ current_time()

template<class TYPE , class FUNCTOR , class ACE_LOCK , typename TIME_POLICY >
ACE_Time_Value ACE_Timer_Queue_T< TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY >::current_time ( )
virtual

Return the current time, using the right time policy and any timer skew defined in derived classes.

Implements ACE_Abstract_Timer_Queue< TYPE >.

◆ dispatch_info()

template<class TYPE , class FUNCTOR , class ACE_LOCK , typename TIME_POLICY >
int ACE_Timer_Queue_T< TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY >::dispatch_info ( const ACE_Time_Value & current_time,
ACE_Timer_Node_Dispatch_Info_T< TYPE > & info )
virtual

Get the dispatch information for a timer whose value is <= current_time. This does not account for <timer_skew>. Returns 1 if there is a node whose value <= current_time else returns a 0.

◆ dispatch_info_i()

template<class TYPE , class FUNCTOR , class ACE_LOCK , typename TIME_POLICY >
int ACE_Timer_Queue_T< TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY >::dispatch_info_i ( const ACE_Time_Value & current_time,
ACE_Timer_Node_Dispatch_Info_T< TYPE > & info )
protectedvirtual

Non-locking version of dispatch_info ()

Reimplemented in ACE_Timer_Hash_T< TYPE, FUNCTOR, ACE_LOCK, BUCKET, TIME_POLICY >.

◆ dump()

template<class TYPE , class FUNCTOR , class ACE_LOCK , typename TIME_POLICY >
void ACE_Timer_Queue_T< TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY >::dump ( ) const
virtual

◆ expire() [1/2]

template<class TYPE , class FUNCTOR , class ACE_LOCK , typename TIME_POLICY >
int ACE_Timer_Queue_T< TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY >::expire ( )
virtual

Run the <functor> for all timers whose values are <= <ACE_OS::gettimeofday>. Also accounts for <timer_skew>.

Depending on the resolution of the underlying OS the system calls like select()/poll() might return at time different than that is specified in the timeout. Suppose the OS guarantees a resolution of t ms. The timeline will look like

        A                   B
        |                   |
        V                   V

|----------—|----------—|----------—|----------—| t t t t t

If you specify a timeout value of A, then the timeout will not occur at A but at the next interval of the timer, which is later than that is expected. Similarly, if your timeout value is equal to B, then the timeout will occur at interval after B. Now depending upon the resolution of your timeouts and the accuracy of the timeouts needed for your application, you should set the value of <timer_skew>. In the above case, if you want the timeout A to fire no later than A, then you should specify your <timer_skew> to be A % t.

The timeout value should be specified via the macro ACE_TIMER_SKEW in your config.h file. The default value is zero.

Things get interesting if the t before the timeout value B is zero i.e your timeout is less than the interval. In that case, you are almost sure of not getting the desired timeout behaviour. Maybe you should look for a better OS :-)

Returns the number of timers canceled.

Implements ACE_Abstract_Timer_Queue< TYPE >.

Reimplemented in ACE_Timer_Hash_T< TYPE, FUNCTOR, ACE_LOCK, BUCKET, TIME_POLICY >, and ACE_Timer_Wheel_T< TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY >.

◆ expire() [2/2]

template<class TYPE , class FUNCTOR , class ACE_LOCK , typename TIME_POLICY >
int ACE_Timer_Queue_T< TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY >::expire ( const ACE_Time_Value & current_time)
virtual

◆ expire_single()

template<class TYPE , class FUNCTOR , class ACE_LOCK , typename TIME_POLICY >
int ACE_Timer_Queue_T< TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY >::expire_single ( ACE_Command_Base & pre_dispatch_command)
virtual

A couple of classes using Timer_Queues need to dispatch a single event at a time. But before they dispatch the event they need to release a lock, signal other threads, etc.

This member function should be used in that case. The additional operations to be called just before dispatching the event, and only if an event will be dispatched, are encapsulated in the ACE_Command_Base object.

Implements ACE_Abstract_Timer_Queue< TYPE >.

◆ free_node()

template<class TYPE , class FUNCTOR , class ACE_LOCK , typename TIME_POLICY >
void ACE_Timer_Queue_T< TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY >::free_node ( ACE_Timer_Node_T< TYPE > * node)
protectedvirtual

Factory method that frees a previously allocated node.

Reimplemented in ACE_Timer_Hash_T< TYPE, FUNCTOR, ACE_LOCK, BUCKET, TIME_POLICY >, and ACE_Timer_Heap_T< TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY >.

◆ gettimeofday() [1/2]

template<class TYPE , class FUNCTOR , class ACE_LOCK , typename TIME_POLICY >
ACE_Time_Value ACE_Timer_Queue_T< TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY >::gettimeofday ( )
virtual

Implement the gettimeofday() virtual function

Implements ACE_Abstract_Timer_Queue< TYPE >.

◆ gettimeofday() [2/2]

template<class TYPE , class FUNCTOR , class ACE_LOCK , typename TIME_POLICY >
void ACE_Timer_Queue_T< TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY >::gettimeofday ( ACE_Time_Value(*)() gettimeofday)
virtual

Allows applications to control how the timer queue gets the time of day.

Deprecated
Use TIME_POLICY support instead. This will only have effect when the TIME_POLICY used is ACE_FPointer_Time_Policy. Other standard ACE time policies will ignore this.

Implements ACE_Abstract_Timer_Queue< TYPE >.

◆ gettimeofday_static()

template<class TYPE , class FUNCTOR , class ACE_LOCK , typename TIME_POLICY >
ACE_Time_Value ACE_Timer_Queue_T< TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY >::gettimeofday_static ( )
inline

Implement an inlined, non-abstract version of gettimeofday(), through this member function the internals of the class can make calls to ACE_OS::gettimeofday() with zero overhead.

◆ mutex()

template<class TYPE , class FUNCTOR , class ACE_LOCK , typename TIME_POLICY >
ACE_LOCK & ACE_Timer_Queue_T< TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY >::mutex ( )

Synchronization variable used by the queue.

◆ postinvoke()

template<class TYPE , class FUNCTOR , class ACE_LOCK , typename TIME_POLICY >
void ACE_Timer_Queue_T< TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY >::postinvoke ( ACE_Timer_Node_Dispatch_Info_T< TYPE > & info,
const ACE_Time_Value & cur_time,
const void * upcall_act )
inline

This method will call the postinvoke() on <functor>.

◆ preinvoke()

template<class TYPE , class FUNCTOR , class ACE_LOCK , typename TIME_POLICY >
void ACE_Timer_Queue_T< TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY >::preinvoke ( ACE_Timer_Node_Dispatch_Info_T< TYPE > & info,
const ACE_Time_Value & cur_time,
const void *& upcall_act )
inline

This method will call the preinvoke() on <functor>.

◆ recompute_next_abs_interval_time()

template<class TYPE , class FUNCTOR , class ACE_LOCK , typename TIME_POLICY >
void ACE_Timer_Queue_T< TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY >::recompute_next_abs_interval_time ( ACE_Timer_Node_T< TYPE > * expired,
const ACE_Time_Value & cur_time )
protected

Recompute when the next time is that this interval timer should fire.

◆ reschedule()

template<class TYPE , class FUNCTOR , class ACE_LOCK , typename TIME_POLICY = ACE_Default_Time_Policy>
virtual void ACE_Timer_Queue_T< TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY >::reschedule ( ACE_Timer_Node_T< TYPE > * )
protectedpure virtual

◆ return_node()

template<class TYPE , class FUNCTOR , class ACE_LOCK , typename TIME_POLICY >
void ACE_Timer_Queue_T< TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY >::return_node ( ACE_Timer_Node_T< TYPE > * node)
virtual

Method used to return a timer node to the queue's ownership after it is returned by a method like <remove_first>.

◆ schedule()

template<class TYPE , class FUNCTOR , class ACE_LOCK , typename TIME_POLICY >
long ACE_Timer_Queue_T< TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY >::schedule ( const TYPE & type,
const void * act,
const ACE_Time_Value & future_time,
const ACE_Time_Value & interval = ACE_Time_Value::zero )
virtual

Implement ACE_Abstract_Timer_Queue<TYPE>::schedule () with the right locking strategy.

Implements ACE_Abstract_Timer_Queue< TYPE >.

◆ schedule_i()

template<class TYPE , class FUNCTOR , class ACE_LOCK , typename TIME_POLICY = ACE_Default_Time_Policy>
virtual long ACE_Timer_Queue_T< TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY >::schedule_i ( const TYPE & type,
const void * act,
const ACE_Time_Value & future_time,
const ACE_Time_Value & interval )
protectedpure virtual

◆ set_time_policy()

template<class TYPE , class FUNCTOR , class ACE_LOCK , typename TIME_POLICY >
void ACE_Timer_Queue_T< TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY >::set_time_policy ( TIME_POLICY const & time_policy)
inline

Allows applications to control how the timer queue gets the time of day.

◆ timer_skew() [1/2]

template<class TYPE , class FUNCTOR , class ACE_LOCK , typename TIME_POLICY >
const ACE_Time_Value & ACE_Timer_Queue_T< TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY >::timer_skew ( ) const
inline

Get the timer skew for the Timer_Queue.

◆ timer_skew() [2/2]

template<class TYPE , class FUNCTOR , class ACE_LOCK , typename TIME_POLICY >
void ACE_Timer_Queue_T< TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY >::timer_skew ( const ACE_Time_Value & skew)
inline

Set the timer skew for the Timer_Queue.

◆ upcall()

template<class TYPE , class FUNCTOR , class ACE_LOCK , typename TIME_POLICY >
void ACE_Timer_Queue_T< TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY >::upcall ( ACE_Timer_Node_Dispatch_Info_T< TYPE > & info,
const ACE_Time_Value & cur_time )
inline

This method will call the timeout() on <functor>.

Member Data Documentation

◆ delete_free_list_

template<class TYPE , class FUNCTOR , class ACE_LOCK , typename TIME_POLICY = ACE_Default_Time_Policy>
bool const ACE_Timer_Queue_T< TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY >::delete_free_list_
protected

Flag to delete only if the class created the <free_list_>

◆ free_list_

template<class TYPE , class FUNCTOR , class ACE_LOCK , typename TIME_POLICY = ACE_Default_Time_Policy>
ACE_Free_List<ACE_Timer_Node_T<TYPE> >* ACE_Timer_Queue_T< TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY >::free_list_
protected

Class that implements a free list.

◆ mutex_

template<class TYPE , class FUNCTOR , class ACE_LOCK , typename TIME_POLICY = ACE_Default_Time_Policy>
ACE_LOCK ACE_Timer_Queue_T< TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY >::mutex_
protected

Synchronization variable for ACE_Timer_Queue.

Note
The right name would be lock_, but HP/C++ will choke on that!

◆ time_policy_

template<class TYPE , class FUNCTOR , class ACE_LOCK , typename TIME_POLICY = ACE_Default_Time_Policy>
TIME_POLICY ACE_Timer_Queue_T< TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY >::time_policy_
protected

The policy to return the current time of day.

◆ timeout_

template<class TYPE , class FUNCTOR , class ACE_LOCK , typename TIME_POLICY = ACE_Default_Time_Policy>
ACE_Time_Value ACE_Timer_Queue_T< TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY >::timeout_
private

Returned by <calculate_timeout>.

◆ timer_skew_

template<class TYPE , class FUNCTOR , class ACE_LOCK , typename TIME_POLICY = ACE_Default_Time_Policy>
ACE_Time_Value ACE_Timer_Queue_T< TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY >::timer_skew_
private

Adjusts for timer skew in various clocks.


The documentation for this class was generated from the following files: