Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

ACE_Thread_Timer_Queue_Adapter Class Template Reference

Adapts a Timer_Queue using a separate thread for dispatching. More...

#include <Timer_Queue_Adapters.h>

Inheritance diagram for ACE_Thread_Timer_Queue_Adapter:

Inheritance graph
[legend]
Collaboration diagram for ACE_Thread_Timer_Queue_Adapter:

Collaboration graph
[legend]
List of all members.

Public Types

typedef TQ TIMER_QUEUE
 Trait for the underlying queue type. More...


Public Methods

 ACE_Thread_Timer_Queue_Adapter (ACE_Thread_Manager *=ACE_Thread_Manager::instance(), TQ *timer_queue=0)
 Creates the timer queue. Activation of the task is the user's responsibility. Optionally a pointer to a timer queue can be passed, when no pointer is passed, a TQ is dynamically created. More...

virtual ~ACE_Thread_Timer_Queue_Adapter (void)
 Destructor. More...

long schedule (ACE_Event_Handler *handler, const void *act, const ACE_Time_Value &future_time, const ACE_Time_Value &interval=ACE_Time_Value::zero)
 Schedule the timer according to the semantics of the <TQ>; wakes up the dispatching thread. More...

int cancel (long timer_id, const void **act=0)
 Cancel the <timer_id> and return the <act> parameter if an address is passed in. Also wakes up the dispatching thread. More...

virtual int svc (void)
 Runs the dispatching thread. More...

virtual void deactivate (void)
 Inform the dispatching thread that it should terminate. More...

ACE_SYNCH_RECURSIVE_MUTEX & mutex (void)
 Access the locking mechanism, useful for iteration. More...

TQ & timer_queue (void)
 
Deprecated:
Access the implementation queue, useful for iteration. Use the method that returns a pointer instead.
More...


int timer_queue (TQ *tq)
 Set a user-specified timer queue. More...

TQ * timer_queue (void) const
 Return the current <TQ>. More...

ACE_thread_t thr_id (void) const
 Return the thread id of our active object. More...

virtual int activate (long flags=THR_NEW_LWP|THR_JOINABLE, int n_threads=1, int force_active=0, long priority=ACE_DEFAULT_THREAD_PRIORITY, int grp_id=-1, ACE_Task_Base *task=0, ACE_hthread_t thread_handles[]=0, void *stack[]=0, size_t stack_size[]=0, ACE_thread_t thread_names[]=0)

Private Attributes

TQ * timer_queue_
 The underlying Timer_Queue. More...

int delete_timer_queue_
 Keeps track of whether we should delete the timer queue (if we didn't create it, then we don't delete it). More...

ACE_SYNCH_RECURSIVE_MUTEX mutex_
 The mutual exclusion mechanism that is required to use the <condition_>. More...

ACE_SYNCH_RECURSIVE_CONDITION condition_
int active_
 When deactivate is called this variable turns to false and the dispatching thread is signalled, to terminate its main loop. More...

ACE_thread_t thr_id_
 Thread id of our active object task. More...


Detailed Description

template<class TQ>
class ACE_Thread_Timer_Queue_Adapter< TQ >

Adapts a Timer_Queue using a separate thread for dispatching.

This implementation of a Timer_Queue uses a separate thread to dispatch the timers. The base queue need not be thread safe, this class takes all the necessary locks.

Note:
This is a case where template parameters will be useful, but (IMHO) the effort and portability problems discourage their use.


Member Typedef Documentation

template<class TQ>
typedef TQ ACE_Thread_Timer_Queue_Adapter::TIMER_QUEUE
 

Trait for the underlying queue type.


Constructor & Destructor Documentation

template<class TQ>
ACE_Thread_Timer_Queue_Adapter< TQ >::ACE_Thread_Timer_Queue_Adapter ACE_Thread_Manager   tm = ACE_Thread_Manager::instance (),
TQ *    timer_queue = 0
 

Creates the timer queue. Activation of the task is the user's responsibility. Optionally a pointer to a timer queue can be passed, when no pointer is passed, a TQ is dynamically created.

template<class TQ>
ACE_Thread_Timer_Queue_Adapter< TQ >::~ACE_Thread_Timer_Queue_Adapter void    [virtual]
 

Destructor.


Member Function Documentation

template<class TQ>
ACE_INLINE int ACE_Thread_Timer_Queue_Adapter< TQ >::activate long    flags = THR_NEW_LWP | THR_JOINABLE,
int    n_threads = 1,
int    force_active = 0,
long    priority = ACE_DEFAULT_THREAD_PRIORITY,
int    grp_id = -1,
ACE_Task_Base   task = 0,
ACE_hthread_t    thread_handles[] = 0,
void *    stack[] = 0,
size_t    stack_size[] = 0,
ACE_thread_t    thread_names[] = 0
[virtual]
 

We override the default activate() method so that we can ensure that only a single thread is ever spawned. Otherwise, too many weird things can happen...

Reimplemented from ACE_Task_Base.

template<class TQ>
int ACE_Thread_Timer_Queue_Adapter< TQ >::cancel long    timer_id,
const void **    act = 0
 

Cancel the <timer_id> and return the <act> parameter if an address is passed in. Also wakes up the dispatching thread.

template<class TQ>
void ACE_Thread_Timer_Queue_Adapter< TQ >::deactivate void    [virtual]
 

Inform the dispatching thread that it should terminate.

template<class TQ>
ACE_SYNCH_RECURSIVE_MUTEX & ACE_Thread_Timer_Queue_Adapter< TQ >::mutex void   
 

Access the locking mechanism, useful for iteration.

template<class TQ>
long ACE_Thread_Timer_Queue_Adapter< TQ >::schedule ACE_Event_Handler   handler,
const void *    act,
const ACE_Time_Value   future_time,
const ACE_Time_Value   interval = ACE_Time_Value::zero
 

Schedule the timer according to the semantics of the <TQ>; wakes up the dispatching thread.

template<class TQ>
int ACE_Thread_Timer_Queue_Adapter< TQ >::svc void    [virtual]
 

Runs the dispatching thread.

Reimplemented from ACE_Task_Base.

template<class TQ>
ACE_INLINE ACE_thread_t ACE_Thread_Timer_Queue_Adapter< TQ >::thr_id void    const
 

Return the thread id of our active object.

template<class TQ>
ACE_INLINE TQ * ACE_Thread_Timer_Queue_Adapter< TQ >::timer_queue void    const
 

Return the current <TQ>.

template<class TQ>
ACE_INLINE int ACE_Thread_Timer_Queue_Adapter< TQ >::timer_queue TQ *    tq
 

Set a user-specified timer queue.

template<class TQ>
ACE_INLINE TQ & ACE_Thread_Timer_Queue_Adapter< TQ >::timer_queue void   
 

Deprecated:
Access the implementation queue, useful for iteration. Use the method that returns a pointer instead.


Member Data Documentation

template<class TQ>
int ACE_Thread_Timer_Queue_Adapter::active_ [private]
 

When deactivate is called this variable turns to false and the dispatching thread is signalled, to terminate its main loop.

template<class TQ>
ACE_SYNCH_RECURSIVE_CONDITION ACE_Thread_Timer_Queue_Adapter::condition_ [private]
 

The dispatching thread sleeps on this condition while waiting to dispatch the next timer; it is used to wake it up if there is a change on the timer queue.

template<class TQ>
int ACE_Thread_Timer_Queue_Adapter::delete_timer_queue_ [private]
 

Keeps track of whether we should delete the timer queue (if we didn't create it, then we don't delete it).

template<class TQ>
ACE_SYNCH_RECURSIVE_MUTEX ACE_Thread_Timer_Queue_Adapter::mutex_ [private]
 

The mutual exclusion mechanism that is required to use the <condition_>.

template<class TQ>
ACE_thread_t ACE_Thread_Timer_Queue_Adapter::thr_id_ [private]
 

Thread id of our active object task.

template<class TQ>
TQ* ACE_Thread_Timer_Queue_Adapter::timer_queue_ [private]
 

The underlying Timer_Queue.


The documentation for this class was generated from the following files:
Generated on Wed Jan 15 19:15:03 2003 for ACE by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001