TAO_EC_MT_Dispatching Class Reference

Dispatching strategy that minimizes mt inversion. More...

#include <EC_MT_Dispatching.h>

Inheritance diagram for TAO_EC_MT_Dispatching:

Inheritance graph
[legend]
Collaboration diagram for TAO_EC_MT_Dispatching:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 TAO_EC_MT_Dispatching (int nthreads, int thread_creation_flags, int thread_priority, int force_activate, TAO_EC_Queue_Full_Service_Object *queue_full_service_object_name)
virtual void activate (void)
virtual void shutdown (void)
virtual void push (TAO_EC_ProxyPushSupplier *proxy, RtecEventComm::PushConsumer_ptr consumer, const RtecEventComm::EventSet &event, TAO_EC_QOS_Info &qos_info)
virtual void push_nocopy (TAO_EC_ProxyPushSupplier *proxy, RtecEventComm::PushConsumer_ptr consumer, RtecEventComm::EventSet &event, TAO_EC_QOS_Info &qos_info)

Private Attributes

ACE_Thread_Manager thread_manager_
 Use our own thread manager.
int nthreads_
 The number of active tasks.
int thread_creation_flags_
int thread_priority_
 The priority of the dispatching threads.
int force_activate_
TAO_EC_Dispatching_Task task_
 The dispatching task.
TAO_SYNCH_MUTEX lock_
 Synchronize access to internal data.
int active_
 Are the threads running?
TAO_EC_Queue_Full_Service_Objectqueue_full_service_object_
 Service Object information.

Detailed Description

Dispatching strategy that minimizes mt inversion.

This strategy uses a single queue, serviced by one or more threads. It's main purpose is to decouple the suppliers from the client execution time, specially in the collocated case.

Definition at line 39 of file EC_MT_Dispatching.h.


Constructor & Destructor Documentation

TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO_EC_MT_Dispatching::TAO_EC_MT_Dispatching ( int  nthreads,
int  thread_creation_flags,
int  thread_priority,
int  force_activate,
TAO_EC_Queue_Full_Service_Object queue_full_service_object_name 
)

Constructor It will create nthreads servicing threads...

Definition at line 10 of file EC_MT_Dispatching.cpp.

00015   :  nthreads_ (nthreads),
00016      thread_creation_flags_ (thread_creation_flags),
00017      thread_priority_ (thread_priority),
00018      force_activate_ (force_activate),
00019      task_(0, service_object),
00020      active_ (0),
00021      queue_full_service_object_ (service_object)
00022 {
00023   this->task_.open (&this->thread_manager_);
00024 }


Member Function Documentation

void TAO_EC_MT_Dispatching::activate ( void   )  [virtual]

Initialize all the data structures, activate any internal threads, etc.

Implements TAO_EC_Dispatching.

Definition at line 27 of file EC_MT_Dispatching.cpp.

References ACE_DEBUG, ACE_ERROR, ACE_GUARD, active_, LM_DEBUG, LM_ERROR, TAO_SYNCH_MUTEX, and THR_BOUND.

Referenced by push_nocopy().

00028 {
00029   ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->lock_);
00030 
00031   if (this->active_ != 0)
00032     return;
00033 
00034   this->active_ = 1;
00035 
00036   if (this->task_.activate (this->thread_creation_flags_,
00037                             this->nthreads_,
00038                             1,
00039                             this->thread_priority_) == -1)
00040     {
00041       if (this->force_activate_ != 0)
00042         {
00043           ACE_DEBUG ((LM_DEBUG,
00044                       "EC (%P|%t) activating dispatching queue at"
00045                       " default priority\n"));
00046           if (this->task_.activate (THR_BOUND, this->nthreads_) == -1)
00047             ACE_ERROR ((LM_ERROR,
00048                         "EC (%P|%t) cannot activate dispatching queue.\n"));
00049         }
00050     }
00051 }

void TAO_EC_MT_Dispatching::push ( TAO_EC_ProxyPushSupplier proxy,
RtecEventComm::PushConsumer_ptr  consumer,
const RtecEventComm::EventSet event,
TAO_EC_QOS_Info qos_info 
) [virtual]

The consumer represented by proxy should receive event. It can use the information in qos_info to determine the event priority (among other things).

Implements TAO_EC_Dispatching.

Definition at line 69 of file EC_MT_Dispatching.cpp.

References push_nocopy().

00073 {
00074   RtecEventComm::EventSet event_copy = event;
00075   this->push_nocopy (proxy, consumer, event_copy, qos_info);
00076 }

void TAO_EC_MT_Dispatching::push_nocopy ( TAO_EC_ProxyPushSupplier proxy,
RtecEventComm::PushConsumer_ptr  consumer,
RtecEventComm::EventSet event,
TAO_EC_QOS_Info qos_info 
) [virtual]

Implements TAO_EC_Dispatching.

Definition at line 79 of file EC_MT_Dispatching.cpp.

References activate(), TAO_EC_Dispatching_Task::push(), and task_.

Referenced by push().

00083 {
00084   // Double checked locking....
00085   if (this->active_ == 0)
00086     this->activate ();
00087 
00088   this->task_.push (proxy, consumer, event);
00089 }

void TAO_EC_MT_Dispatching::shutdown ( void   )  [virtual]

Deactivate any internal threads and cleanup internal data structures, it should only return once the threads have finished their jobs.

Implements TAO_EC_Dispatching.

Definition at line 54 of file EC_MT_Dispatching.cpp.

References ACE_GUARD, nthreads_, TAO_SYNCH_MUTEX, thread_manager_, and ACE_Thread_Manager::wait().

00055 {
00056   ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->lock_);
00057 
00058   if (this->active_ == 0)
00059     return;
00060 
00061   for (int i = 0; i < this->nthreads_; ++i)
00062     {
00063       this->task_.putq (new TAO_EC_Shutdown_Task_Command);
00064     }
00065   this->thread_manager_.wait ();
00066 }


Member Data Documentation

int TAO_EC_MT_Dispatching::active_ [private]

Are the threads running?

Definition at line 87 of file EC_MT_Dispatching.h.

Referenced by activate().

int TAO_EC_MT_Dispatching::force_activate_ [private]

If activation at the requested priority fails then we fallback on the defaults for thread activation.

Definition at line 78 of file EC_MT_Dispatching.h.

TAO_SYNCH_MUTEX TAO_EC_MT_Dispatching::lock_ [private]

Synchronize access to internal data.

Definition at line 84 of file EC_MT_Dispatching.h.

int TAO_EC_MT_Dispatching::nthreads_ [private]

The number of active tasks.

Definition at line 67 of file EC_MT_Dispatching.h.

Referenced by shutdown().

TAO_EC_Queue_Full_Service_Object* TAO_EC_MT_Dispatching::queue_full_service_object_ [private]

Service Object information.

Definition at line 90 of file EC_MT_Dispatching.h.

TAO_EC_Dispatching_Task TAO_EC_MT_Dispatching::task_ [private]

The dispatching task.

Definition at line 81 of file EC_MT_Dispatching.h.

Referenced by push_nocopy().

int TAO_EC_MT_Dispatching::thread_creation_flags_ [private]

The flags (THR_BOUND, THR_NEW_LWP, etc.) used to create the dispatching threads.

Definition at line 71 of file EC_MT_Dispatching.h.

ACE_Thread_Manager TAO_EC_MT_Dispatching::thread_manager_ [private]

Use our own thread manager.

Definition at line 64 of file EC_MT_Dispatching.h.

Referenced by shutdown().

int TAO_EC_MT_Dispatching::thread_priority_ [private]

The priority of the dispatching threads.

Definition at line 74 of file EC_MT_Dispatching.h.


The documentation for this class was generated from the following files:
Generated on Tue Feb 2 17:44:31 2010 for TAO_RTEvent by  doxygen 1.4.7