TAO_EC_Dispatching_Task Class Reference

Implement the dispatching queues for FIFO and Priority dispatching. More...

#include <EC_Dispatching_Task.h>

Inheritance diagram for TAO_EC_Dispatching_Task:

Inheritance graph
[legend]
Collaboration diagram for TAO_EC_Dispatching_Task:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 TAO_EC_Dispatching_Task (ACE_Thread_Manager *thr_manager=0, TAO_EC_Queue_Full_Service_Object *queue_full_service_object=0)
 Constructor.

virtual int svc (void)
 Process the events in the queue.

virtual void push (TAO_EC_ProxyPushSupplier *proxy, RtecEventComm::PushConsumer_ptr consumer, RtecEventComm::EventSet &event ACE_ENV_ARG_DECL)

Private Attributes

ACE_Allocatorallocator_
 An per-task allocator.

ACE_Locked_Data_Block< ACE_Lock_Adapter<
TAO_SYNCH_MUTEX > > 
data_block_
 Helper data structure to minimize memory allocations...

TAO_EC_Queue the_queue_
 The queue.

TAO_EC_Queue_Full_Service_Objectqueue_full_service_object_

Detailed Description

Implement the dispatching queues for FIFO and Priority dispatching.

Definition at line 101 of file EC_Dispatching_Task.h.


Constructor & Destructor Documentation

ACE_INLINE TAO_EC_Dispatching_Task::TAO_EC_Dispatching_Task ACE_Thread_Manager thr_manager = 0,
TAO_EC_Queue_Full_Service_Object queue_full_service_object = 0
 

Constructor.

Definition at line 32 of file EC_Dispatching_Task.i.

References ACE_SYNCH, ACE_Task< ACE_SYNCH >::msg_queue(), TAO_EC_QUEUE_HWM, and TAO_EC_QUEUE_LWM.

00033   :  ACE_Task<ACE_SYNCH> (thr_manager),
00034      allocator_ (0),
00035      the_queue_ (TAO_EC_QUEUE_HWM, TAO_EC_QUEUE_LWM),
00036      queue_full_service_object_ (so)
00037 {
00038   this->msg_queue (&this->the_queue_);
00039 }


Member Function Documentation

void TAO_EC_Dispatching_Task::push TAO_EC_ProxyPushSupplier proxy,
RtecEventComm::PushConsumer_ptr  consumer,
RtecEventComm::EventSet &event  ACE_ENV_ARG_DECL
[virtual]
 

Definition at line 144 of file EC_Dispatching_Task.cpp.

References ACE_CHECK, ACE_ENV_ARG_PARAMETER, ACE_THROW, RtecEventComm::EventSet, ACE_Allocator::instance(), ACE_Message_Queue< ACE_SYNCH_USE >::is_full(), ACE_Allocator::malloc(), ACE_Task< ACE_SYNCH >::msg_queue(), ACE_Task< ACE_SYNCH >::putq(), TAO_EC_Queue_Full_Service_Object::queue_full_action(), and queue_full_service_object_.

Referenced by TAO_EC_RTCORBA_Dispatching::push_nocopy(), and TAO_EC_Priority_Dispatching::push_nocopy().

00148 {
00149   if (this->msg_queue()->is_full ())
00150     {
00151       int action =
00152         this->queue_full_service_object_->queue_full_action (this, proxy,
00153                                                              consumer, event
00154                                                              ACE_ENV_ARG_PARAMETER);
00155       ACE_CHECK;
00156 
00157       if (action == TAO_EC_Queue_Full_Service_Object::SILENTLY_DISCARD)
00158         return;
00159       // if action == WAIT_TO_EMPTY then we just go ahead and queue it
00160     }
00161 
00162   if (this->allocator_ == 0)
00163     this->allocator_ = ACE_Allocator::instance ();
00164 
00165   void* buf = this->allocator_->malloc (sizeof (TAO_EC_Push_Command));
00166 
00167   if (buf == 0)
00168     ACE_THROW (CORBA::NO_MEMORY (TAO::VMCID,
00169                                  CORBA::COMPLETED_NO));
00170 
00171   ACE_Message_Block *mb =
00172     new (buf) TAO_EC_Push_Command (proxy,
00173                                    consumer,
00174                                    event,
00175                                    this->data_block_.duplicate (),
00176                                    this->allocator_);
00177   this->putq (mb);
00178 }

int TAO_EC_Dispatching_Task::svc void   )  [virtual]
 

Process the events in the queue.

Reimplemented from ACE_Task_Base.

Definition at line 101 of file EC_Dispatching_Task.cpp.

References ACE_ANY_EXCEPTION, ACE_CATCHANY, ACE_ENDTRY, ACE_ENV_SINGLE_ARG_PARAMETER, ACE_ERROR, ACE_PRINT_EXCEPTION, ACE_TRY_CHECK, ACE_TRY_NEW_ENV, ESHUTDOWN, TAO_EC_Dispatch_Command::execute(), ACE_Task< ACE_SYNCH >::getq(), ACE_OS::last_error(), LM_ERROR, and ACE_Message_Block::release().

00102 {
00103   int done = 0;
00104   while (!done)
00105     {
00106       ACE_TRY_NEW_ENV
00107         {
00108           ACE_Message_Block *mb = 0;
00109           if (this->getq (mb) == -1)
00110             if (ACE_OS::last_error () == ESHUTDOWN)
00111               return 0;
00112           else
00113             ACE_ERROR ((LM_ERROR,
00114                         "EC (%P|%t) getq error in Dispatching Queue\n"));
00115 
00116           TAO_EC_Dispatch_Command *command =
00117             dynamic_cast<TAO_EC_Dispatch_Command*> (mb);
00118 
00119           if (command == 0)
00120             {
00121               ACE_Message_Block::release (mb);
00122               continue;
00123             }
00124 
00125           int result = command->execute (ACE_ENV_SINGLE_ARG_PARAMETER);
00126           ACE_TRY_CHECK;
00127 
00128           ACE_Message_Block::release (mb);
00129 
00130           if (result == -1)
00131             done = 1;
00132         }
00133       ACE_CATCHANY
00134         {
00135           ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
00136                                "EC (%P|%t) exception in dispatching queue");
00137         }
00138       ACE_ENDTRY;
00139     }
00140   return 0;
00141 }


Member Data Documentation

ACE_Allocator* TAO_EC_Dispatching_Task::allocator_ [private]
 

An per-task allocator.

Definition at line 117 of file EC_Dispatching_Task.h.

ACE_Locked_Data_Block<ACE_Lock_Adapter<TAO_SYNCH_MUTEX> > TAO_EC_Dispatching_Task::data_block_ [private]
 

Helper data structure to minimize memory allocations...

Definition at line 120 of file EC_Dispatching_Task.h.

TAO_EC_Queue_Full_Service_Object* TAO_EC_Dispatching_Task::queue_full_service_object_ [private]
 

Definition at line 125 of file EC_Dispatching_Task.h.

Referenced by push().

TAO_EC_Queue TAO_EC_Dispatching_Task::the_queue_ [private]
 

The queue.

Definition at line 123 of file EC_Dispatching_Task.h.


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 13:14:41 2006 for TAO_RTEvent by doxygen 1.3.6