EC_RTCORBA_Dispatching.cpp

Go to the documentation of this file.
00001 // EC_RTCORBA_Dispatching.cpp,v 1.8 2006/03/14 06:14:25 jtc Exp
00002 
00003 #include "orbsvcs/Event/EC_RTCORBA_Dispatching.h"
00004 #include "tao/RTCORBA/Priority_Mapping.h"
00005 
00006 ACE_RCSID(Event, EC_RTCORBA_Dispatching, "EC_RTCORBA_Dispatching.cpp,v 1.8 2006/03/14 06:14:25 jtc Exp")
00007 
00008 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00009 
00010 TAO_EC_RTCORBA_Dispatching::
00011   TAO_EC_RTCORBA_Dispatching (const RTCORBA::ThreadpoolLanes &lanes,
00012                               RTCORBA::PriorityMapping *mapping,
00013                               RTCORBA::Current_ptr current)
00014     :  lanes_ (lanes)
00015     , priority_mapping_ (mapping)
00016     , current_ (RTCORBA::Current::_duplicate (current))
00017 {
00018   CORBA::ULong number_lanes = this->lanes_.length ();
00019   ACE_NEW (this->tasks_, TAO_EC_Dispatching_Task[number_lanes]);
00020   for (CORBA::ULong i = 0; i != this->lanes_.length (); ++i)
00021     this->tasks_[i].thr_mgr (&this->thread_manager_);
00022 }
00023 
00024 TAO_EC_RTCORBA_Dispatching::~TAO_EC_RTCORBA_Dispatching (void)
00025 {
00026   delete[] this->tasks_;
00027 }
00028 
00029 void
00030 TAO_EC_RTCORBA_Dispatching::activate (void)
00031 {
00032   for (CORBA::ULong i = 0; i != this->lanes_.length (); ++i)
00033     {
00034       CORBA::ULong nthreads = this->lanes_[i].static_threads;
00035       if (nthreads == 0)
00036         {
00037           nthreads = 1;
00038         }
00039       RTCORBA::Priority corba_priority = this->lanes_[i].lane_priority;
00040       RTCORBA::NativePriority native_priority;
00041       if (this->priority_mapping_->to_native (corba_priority,
00042                                               native_priority) != 0)
00043         {
00044           this->tasks_[i].activate (
00045               THR_SCHED_FIFO | THR_NEW_LWP | THR_JOINABLE,
00046               nthreads, 0,
00047               native_priority);
00048         }
00049     }
00050 }
00051 
00052 void
00053 TAO_EC_RTCORBA_Dispatching::shutdown (void)
00054 {
00055   for (CORBA::ULong i = 0; i != this->lanes_.length (); ++i)
00056     {
00057       int nthreads =
00058         this->thread_manager_.num_threads_in_task (&this->tasks_[i]);
00059       if (nthreads <= 0)
00060         continue;
00061       for (int j = 0; j != nthreads; ++j)
00062         {
00063           this->tasks_[i].putq (new TAO_EC_Shutdown_Task_Command);
00064         }
00065     }
00066   this->thread_manager_.wait ();
00067 }
00068 
00069 void
00070 TAO_EC_RTCORBA_Dispatching::push (TAO_EC_ProxyPushSupplier* proxy,
00071                              RtecEventComm::PushConsumer_ptr consumer,
00072                              const RtecEventComm::EventSet& event,
00073                              TAO_EC_QOS_Info& qos_info
00074                              ACE_ENV_ARG_DECL)
00075 {
00076   RtecEventComm::EventSet event_copy = event;
00077   this->push_nocopy (proxy, consumer, event_copy, qos_info ACE_ENV_ARG_PARAMETER);
00078 }
00079 
00080 void
00081 TAO_EC_RTCORBA_Dispatching::push_nocopy (TAO_EC_ProxyPushSupplier* proxy,
00082                                          RtecEventComm::PushConsumer_ptr consumer,
00083                                          RtecEventComm::EventSet& event,
00084                                          TAO_EC_QOS_Info&
00085                                          ACE_ENV_ARG_DECL)
00086 {
00087   RTCORBA::Priority current_priority =
00088     this->current_->the_priority (ACE_ENV_SINGLE_ARG_PARAMETER);
00089   ACE_CHECK;
00090 
00091   for (CORBA::ULong i = 0; i != this->lanes_.length (); ++i)
00092     {
00093       if (this->lanes_[i].lane_priority != current_priority)
00094         continue;
00095 
00096       // @@ If there were no threads available we may need to create
00097       // some...
00098 
00099       this->tasks_[i].push (proxy, consumer, event
00100                             ACE_ENV_ARG_PARAMETER);
00101       ACE_CHECK;
00102       break;
00103     }
00104 }
00105 
00106 TAO_END_VERSIONED_NAMESPACE_DECL

Generated on Thu Nov 9 13:11:09 2006 for TAO_RTEvent by doxygen 1.3.6