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)

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 99 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.inl.

References ACE_Task< ACE_SYNCH >::msg_queue().

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 
) [virtual]

Definition at line 140 of file EC_Dispatching_Task.cpp.

References allocator_, CORBA::COMPLETED_NO, ACE_Allocator::instance(), ACE_Allocator::malloc(), ACE_Task< ACE_SYNCH >::putq(), TAO_EC_Queue_Full_Service_Object::queue_full_action(), queue_full_service_object_, TAO_EC_Queue_Full_Service_Object::SILENTLY_DISCARD, and TAO::VMCID.

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

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

int TAO_EC_Dispatching_Task::svc ( void   )  [virtual]

Process the events in the queue.

Reimplemented from ACE_Task_Base.

Definition at line 100 of file EC_Dispatching_Task.cpp.

References CORBA::Exception::_tao_print_exception(), ACE_ERROR, TAO_EC_Dispatch_Command::execute(), ACE_OS::last_error(), LM_ERROR, and ACE_Message_Block::release().

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


Member Data Documentation

ACE_Allocator* TAO_EC_Dispatching_Task::allocator_ [private]

An per-task allocator.

Definition at line 114 of file EC_Dispatching_Task.h.

Referenced by push().

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 117 of file EC_Dispatching_Task.h.

TAO_EC_Queue_Full_Service_Object* TAO_EC_Dispatching_Task::queue_full_service_object_ [private]

Definition at line 122 of file EC_Dispatching_Task.h.

Referenced by push().

TAO_EC_Queue TAO_EC_Dispatching_Task::the_queue_ [private]

The queue.

Definition at line 120 of file EC_Dispatching_Task.h.


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