#include <CEC_Reactive_Pulling_Strategy.h>
Inheritance diagram for TAO_CEC_Reactive_Pulling_Strategy:
Public Member Functions | |
TAO_CEC_Reactive_Pulling_Strategy (const ACE_Time_Value &rate, const ACE_Time_Value &relative_timeout, TAO_CEC_EventChannel *event_channel, CORBA::ORB_ptr orb) | |
void | handle_timeout (const ACE_Time_Value &tv, const void *arg) |
Receive the timeout from the adapter. | |
virtual void | activate (void) |
virtual void | shutdown (void) |
Private Attributes | |
TAO_CEC_Pulling_Strategy_Adapter | adapter_ |
The Adapter for the reactor events. | |
ACE_Time_Value | rate_ |
The polling rate. | |
ACE_Time_Value | relative_timeout_ |
The relative timeout. | |
TAO_CEC_EventChannel * | event_channel_ |
The event channel. | |
CORBA::ORB_var | orb_ |
The ORB. | |
CORBA::PolicyCurrent_var | policy_current_ |
To control the timeout policy in the thread. | |
CORBA::PolicyList | policy_list_ |
Precomputed policy list to the set timeout. | |
ACE_Reactor * | reactor_ |
The ORB reactor. | |
long | timer_id_ |
The timer id. |
The events are dispatched in FIFO ordering, using the invoking thread to push the event to the consumer.
Definition at line 75 of file CEC_Reactive_Pulling_Strategy.h.
TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO_CEC_Reactive_Pulling_Strategy::TAO_CEC_Reactive_Pulling_Strategy | ( | const ACE_Time_Value & | rate, | |
const ACE_Time_Value & | relative_timeout, | |||
TAO_CEC_EventChannel * | event_channel, | |||
CORBA::ORB_ptr | orb | |||
) |
The scheduler is used to find the range of priorities and similar info.
Definition at line 29 of file CEC_Reactive_Pulling_Strategy.cpp.
References orb_.
00033 : adapter_ (this), 00034 rate_ (rate), 00035 relative_timeout_ (relative_timeout), 00036 event_channel_ (event_channel), 00037 orb_ (CORBA::ORB::_duplicate (orb)) 00038 #if defined (TAO_HAS_CORBA_MESSAGING) && TAO_HAS_CORBA_MESSAGING != 0 00039 // Initialise timer_id_ to an invalid timer id, so that in case we don't 00040 // schedule a timer, we don't cancel a random timer at shutdown 00041 , timer_id_ (-1) 00042 #endif /* TAO_HAS_CORBA_MESSAGING */ 00043 { 00044 this->reactor_ = 00045 this->orb_->orb_core ()->reactor (); 00046 }
void TAO_CEC_Reactive_Pulling_Strategy::activate | ( | void | ) | [virtual] |
Initialize all the data structures, activate any internal threads, etc.
Implements TAO_CEC_Pulling_Strategy.
Definition at line 91 of file CEC_Reactive_Pulling_Strategy.cpp.
References TAO_Pseudo_Var_T< T >::in(), orb_, policy_current_, policy_list_, reactor_, ACE_Reactor::schedule_timer(), and timer_id_.
00092 { 00093 #if defined (TAO_HAS_CORBA_MESSAGING) && TAO_HAS_CORBA_MESSAGING != 0 00094 timer_id_ = this->reactor_->schedule_timer (&this->adapter_, 00095 0, 00096 this->rate_, 00097 this->rate_); 00098 if (timer_id_ == -1) 00099 return; 00100 00101 try 00102 { 00103 // Get the PolicyCurrent object 00104 CORBA::Object_var tmp = 00105 this->orb_->resolve_initial_references ("PolicyCurrent"); 00106 00107 this->policy_current_ = 00108 CORBA::PolicyCurrent::_narrow (tmp.in ()); 00109 00110 // Pre-compute the policy list to the set the right timeout 00111 // value... 00112 // We need to convert the relative timeout into 100's of nano seconds. 00113 TimeBase::TimeT timeout; 00114 ORBSVCS_Time::Time_Value_to_TimeT (timeout, 00115 this->relative_timeout_); 00116 CORBA::Any any; 00117 any <<= timeout; 00118 00119 this->policy_list_.length (1); 00120 this->policy_list_[0] = 00121 this->orb_->create_policy ( 00122 Messaging::RELATIVE_RT_TIMEOUT_POLICY_TYPE, 00123 any); 00124 } 00125 catch (const CORBA::Exception&) 00126 { 00127 } 00128 #endif /* TAO_HAS_CORBA_MESSAGING */ 00129 }
void TAO_CEC_Reactive_Pulling_Strategy::handle_timeout | ( | const ACE_Time_Value & | tv, | |
const void * | arg | |||
) |
Receive the timeout from the adapter.
Definition at line 49 of file CEC_Reactive_Pulling_Strategy.cpp.
References event_channel_, TAO_CEC_SupplierAdmin::for_each(), policy_current_, TAO_CEC_EventChannel::supplier_admin(), and TAO_CEC_EventChannel::supplier_control().
Referenced by TAO_CEC_Pulling_Strategy_Adapter::handle_timeout().
00052 { 00053 try 00054 { 00055 // Query the state of the Current object *before* we initiate 00056 // the iteration... 00057 CORBA::PolicyTypeSeq types; 00058 CORBA::PolicyList_var policies = 00059 this->policy_current_->get_policy_overrides (types); 00060 00061 // Change the timeout 00062 this->policy_current_->set_policy_overrides (this->policy_list_, 00063 CORBA::ADD_OVERRIDE); 00064 00065 try 00066 { 00067 TAO_CEC_Pull_Event worker (this->event_channel_->consumer_admin (), 00068 this->event_channel_->supplier_control ()); 00069 00070 this->event_channel_->supplier_admin ()->for_each (&worker); 00071 } 00072 catch (const CORBA::Exception&) 00073 { 00074 // Ignore all exceptions 00075 } 00076 00077 this->policy_current_->set_policy_overrides (policies.in (), 00078 CORBA::SET_OVERRIDE); 00079 for (CORBA::ULong i = 0; i != policies->length (); ++i) 00080 { 00081 policies[i]->destroy (); 00082 } 00083 } 00084 catch (const CORBA::Exception&) 00085 { 00086 // Ignore all exceptions 00087 } 00088 }
void TAO_CEC_Reactive_Pulling_Strategy::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_CEC_Pulling_Strategy.
Definition at line 132 of file CEC_Reactive_Pulling_Strategy.cpp.
References adapter_, ACE_Reactor::cancel_timer(), ACE_Event_Handler::reactor(), reactor_, and timer_id_.
00133 { 00134 #if defined (TAO_HAS_CORBA_MESSAGING) && TAO_HAS_CORBA_MESSAGING != 0 00135 this->reactor_->cancel_timer (timer_id_); 00136 #endif /* TAO_HAS_CORBA_MESSAGING */ 00137 this->adapter_.reactor (0); 00138 }
The Adapter for the reactor events.
Definition at line 95 of file CEC_Reactive_Pulling_Strategy.h.
Referenced by shutdown().
The event channel.
Definition at line 104 of file CEC_Reactive_Pulling_Strategy.h.
Referenced by handle_timeout().
CORBA::PolicyCurrent_var TAO_CEC_Reactive_Pulling_Strategy::policy_current_ [private] |
To control the timeout policy in the thread.
Definition at line 110 of file CEC_Reactive_Pulling_Strategy.h.
Referenced by activate(), and handle_timeout().
CORBA::PolicyList TAO_CEC_Reactive_Pulling_Strategy::policy_list_ [private] |
Precomputed policy list to the set timeout.
Definition at line 113 of file CEC_Reactive_Pulling_Strategy.h.
Referenced by activate().
The ORB reactor.
Definition at line 116 of file CEC_Reactive_Pulling_Strategy.h.
Referenced by activate(), and shutdown().
long TAO_CEC_Reactive_Pulling_Strategy::timer_id_ [private] |
The timer id.
Definition at line 120 of file CEC_Reactive_Pulling_Strategy.h.
Referenced by activate(), and shutdown().