#include <CEC_ProxyPullSupplier.h>
Collaboration diagram for TAO_CEC_ProxyPullSupplier:
Public Types | |
typedef CosEventChannelAdmin::ProxyPullSupplier_ptr | _ptr_type |
typedef CosEventChannelAdmin::ProxyPullSupplier_var | _var_type |
Public Member Functions | |
TAO_CEC_ProxyPullSupplier (TAO_CEC_EventChannel *event_channel, const ACE_Time_Value &timeout) | |
constructor... | |
virtual | ~TAO_CEC_ProxyPullSupplier (void) |
destructor... | |
virtual void | activate (CosEventChannelAdmin::ProxyPullSupplier_ptr &activated_proxy) |
Activate in the POA. | |
virtual void | deactivate (void) |
Deactivate from the POA. | |
CORBA::Boolean | is_connected (void) const |
Return 0 if no consumer is connected... | |
CosEventComm::PullConsumer_ptr | consumer (void) const |
virtual void | shutdown (void) |
The event channel is shutting down. | |
CORBA::Boolean | consumer_non_existent (CORBA::Boolean_out disconnected) |
void | push (const CORBA::Any &event) |
Push an event into the queue. | |
virtual void | connect_pull_consumer (CosEventComm::PullConsumer_ptr pull_consumer) |
virtual CORBA::Any * | pull (void) |
virtual CORBA::Any * | try_pull (CORBA::Boolean_out has_event) |
virtual void | disconnect_pull_supplier (void) |
CORBA::ULong | _incr_refcnt (void) |
Increment and decrement the reference count. | |
CORBA::ULong | _decr_refcnt (void) |
virtual PortableServer::POA_ptr | _default_POA (void) |
virtual void | _add_ref (void) |
virtual void | _remove_ref (void) |
Protected Member Functions | |
void | consumer (CosEventComm::PullConsumer_ptr consumer) |
void | consumer_i (CosEventComm::PullConsumer_ptr consumer) |
CORBA::Boolean | is_connected_i (void) const |
The private version (without locking) of is_connected(). | |
void | cleanup_i (void) |
Release the child and the consumer. | |
CosEventComm::PullConsumer_ptr | apply_policy (CosEventComm::PullConsumer_ptr c) |
Private Attributes | |
TAO_CEC_EventChannel * | event_channel_ |
The Event Channel that owns this object. | |
ACE_Time_Value | timeout_ |
ACE_Lock * | lock_ |
The locking strategy. | |
CORBA::ULong | refcount_ |
The reference count. | |
CosEventComm::PullConsumer_var | consumer_ |
CosEventComm::PullConsumer_var | nopolicy_consumer_ |
The consumer without any policies applied. | |
int | connected_ |
PortableServer::POA_var | default_POA_ |
Store the default POA. | |
TAO_SYNCH_MUTEX | queue_lock_ |
Use a message queue to pass the. | |
TAO_SYNCH_CONDITION | wait_not_empty_ |
ACE_Unbounded_Queue< CORBA::Any > | queue_ |
Implement the CosEventChannelAdmin::ProxyPullSupplier interface, remember that this class is used to communicate with a PullConsumer, so, in effect, this is the ambassador for a consumer inside the event channel. = MEMORY MANAGMENT It does not assume ownership of the TAO_CEC_Dispatching object. It makes a copy of the ConsumerQOS and the consumer object reference. = LOCKING Locking is strategized, the event channel acts as a factory for the locking strategies.
Definition at line 53 of file CEC_ProxyPullSupplier.h.
typedef CosEventChannelAdmin::ProxyPullSupplier_ptr TAO_CEC_ProxyPullSupplier::_ptr_type |
Definition at line 56 of file CEC_ProxyPullSupplier.h.
typedef CosEventChannelAdmin::ProxyPullSupplier_var TAO_CEC_ProxyPullSupplier::_var_type |
Definition at line 57 of file CEC_ProxyPullSupplier.h.
TAO_CEC_ProxyPullSupplier::TAO_CEC_ProxyPullSupplier | ( | TAO_CEC_EventChannel * | event_channel, | |
const ACE_Time_Value & | timeout | |||
) |
constructor...
Definition at line 22 of file CEC_ProxyPullSupplier.cpp.
00023 : event_channel_ (ec), 00024 timeout_ (timeout), 00025 refcount_ (1), 00026 connected_ (0), 00027 wait_not_empty_ (queue_lock_) 00028 { 00029 this->lock_ = 00030 this->event_channel_->create_supplier_lock (); 00031 00032 this->default_POA_ = 00033 this->event_channel_->supplier_poa (); 00034 00035 this->event_channel_->get_servant_retry_map ().bind (this, 0); 00036 }
TAO_CEC_ProxyPullSupplier::~TAO_CEC_ProxyPullSupplier | ( | void | ) | [virtual] |
destructor...
Definition at line 38 of file CEC_ProxyPullSupplier.cpp.
References TAO_CEC_EventChannel::destroy_supplier_lock(), event_channel_, and TAO_CEC_EventChannel::get_servant_retry_map().
00039 { 00040 this->event_channel_->get_servant_retry_map ().unbind (this); 00041 this->event_channel_->destroy_supplier_lock (this->lock_); 00042 }
void TAO_CEC_ProxyPullSupplier::_add_ref | ( | void | ) | [virtual] |
Definition at line 345 of file CEC_ProxyPullSupplier.cpp.
References _incr_refcnt().
00346 { 00347 this->_incr_refcnt (); 00348 }
CORBA::ULong TAO_CEC_ProxyPullSupplier::_decr_refcnt | ( | void | ) |
Definition at line 214 of file CEC_ProxyPullSupplier.cpp.
References ACE_GUARD_RETURN, TAO_CEC_EventChannel::destroy_proxy(), event_channel_, and refcount_.
Referenced by _remove_ref().
00215 { 00216 { 00217 ACE_GUARD_RETURN (ACE_Lock, ace_mon, *this->lock_, 0); 00218 this->refcount_--; 00219 if (this->refcount_ != 0) 00220 return this->refcount_; 00221 } 00222 00223 // Notify the event channel 00224 this->event_channel_->destroy_proxy (this); 00225 return 0; 00226 }
PortableServer::POA_ptr TAO_CEC_ProxyPullSupplier::_default_POA | ( | void | ) | [virtual] |
CORBA::ULong TAO_CEC_ProxyPullSupplier::_incr_refcnt | ( | void | ) |
Increment and decrement the reference count.
Definition at line 207 of file CEC_ProxyPullSupplier.cpp.
References ACE_GUARD_RETURN, and refcount_.
Referenced by _add_ref().
00208 { 00209 ACE_GUARD_RETURN (ACE_Lock, ace_mon, *this->lock_, 0); 00210 return this->refcount_++; 00211 }
void TAO_CEC_ProxyPullSupplier::_remove_ref | ( | void | ) | [virtual] |
Definition at line 351 of file CEC_ProxyPullSupplier.cpp.
References _decr_refcnt().
00352 { 00353 this->_decr_refcnt (); 00354 }
void TAO_CEC_ProxyPullSupplier::activate | ( | CosEventChannelAdmin::ProxyPullSupplier_ptr & | activated_proxy | ) | [virtual] |
Activate in the POA.
Definition at line 45 of file CEC_ProxyPullSupplier.cpp.
00047 { 00048 CosEventChannelAdmin::ProxyPullSupplier_var result; 00049 try 00050 { 00051 result = this->_this (); 00052 } 00053 catch (const CORBA::Exception&) 00054 { 00055 result = CosEventChannelAdmin::ProxyPullSupplier::_nil (); 00056 } 00057 activated_proxy = result._retn (); 00058 }
CosEventComm::PullConsumer_ptr TAO_CEC_ProxyPullSupplier::apply_policy | ( | CosEventComm::PullConsumer_ptr | c | ) | [protected] |
Assigns the parameter to both consumer_ and nopolicy_consumer_, and applies policies (when appropriate) to consumer_.
Definition at line 271 of file CEC_ProxyPullSupplier.cpp.
References event_channel_, TAO_Pseudo_Var_T< T >::in(), CORBA::is_nil(), nopolicy_consumer_, and ACE_Time_Value::zero.
Referenced by connect_pull_consumer().
00272 { 00273 if (CORBA::is_nil (pre)) return pre; 00274 this->nopolicy_consumer_ = CosEventComm::PullConsumer::_duplicate (pre); 00275 #if defined (TAO_HAS_CORBA_MESSAGING) && TAO_HAS_CORBA_MESSAGING != 0 00276 CosEventComm::PullConsumer_var post = 00277 CosEventComm::PullConsumer::_duplicate (pre); 00278 if (this->timeout_ > ACE_Time_Value::zero) 00279 { 00280 CORBA::PolicyList policy_list; 00281 policy_list.length (1); 00282 policy_list[0] = this->event_channel_-> 00283 create_roundtrip_timeout_policy (this->timeout_); 00284 00285 CORBA::Object_var post_obj = pre->_set_policy_overrides 00286 (policy_list, CORBA::ADD_OVERRIDE); 00287 post = CosEventComm::PullConsumer::_narrow(post_obj.in ()); 00288 00289 policy_list[0]->destroy (); 00290 policy_list.length (0); 00291 } 00292 return post._retn (); 00293 #else 00294 return CosEventComm::PullConsumer::_duplicate (pre); 00295 #endif /* TAO_HAS_CORBA_MESSAGING */ 00296 }
void TAO_CEC_ProxyPullSupplier::cleanup_i | ( | void | ) | [protected] |
Release the child and the consumer.
Definition at line 199 of file CEC_ProxyPullSupplier.cpp.
References connected_, and consumer_.
Referenced by connect_pull_consumer(), and disconnect_pull_supplier().
00200 { 00201 this->consumer_ = 00202 CosEventComm::PullConsumer::_nil (); 00203 this->connected_ = 0; 00204 }
void TAO_CEC_ProxyPullSupplier::connect_pull_consumer | ( | CosEventComm::PullConsumer_ptr | pull_consumer | ) | [virtual] |
Definition at line 229 of file CEC_ProxyPullSupplier.cpp.
References ACE_GUARD_THROW_EX, apply_policy(), cleanup_i(), TAO_CEC_EventChannel::connected(), connected_, consumer_, event_channel_, TAO_CEC_EventChannel::reconnected(), and TAO_CEC_Unlock.
00231 { 00232 { 00233 ACE_GUARD_THROW_EX ( 00234 ACE_Lock, ace_mon, *this->lock_, 00235 CORBA::INTERNAL ()); 00236 // @@ CosEventChannelAdmin::EventChannel::SYNCHRONIZATION_ERROR ()); 00237 00238 if (this->is_connected_i ()) 00239 { 00240 if (this->event_channel_->consumer_reconnect () == 0) 00241 throw CosEventChannelAdmin::AlreadyConnected (); 00242 00243 // Re-connections are allowed.... 00244 this->cleanup_i (); 00245 00246 this->consumer_ = apply_policy (pull_consumer); 00247 this->connected_ = 1; 00248 00249 TAO_CEC_Unlock reverse_lock (*this->lock_); 00250 00251 { 00252 ACE_GUARD_THROW_EX ( 00253 TAO_CEC_Unlock, ace_mon, reverse_lock, 00254 CORBA::INTERNAL ()); 00255 // @@ CosEventChannelAdmin::EventChannel::SYNCHRONIZATION_ERROR ()); 00256 00257 this->event_channel_->reconnected (this); 00258 } 00259 return; 00260 } 00261 00262 this->consumer_ = apply_policy (pull_consumer); 00263 this->connected_ = 1; 00264 } 00265 00266 // Notify the event channel... 00267 this->event_channel_->connected (this); 00268 }
ACE_INLINE void TAO_CEC_ProxyPullSupplier::consumer | ( | CosEventComm::PullConsumer_ptr | consumer | ) | [protected] |
Set the consumer, used by some implementations to change the policies used when invoking operations on the consumer.
Definition at line 36 of file CEC_ProxyPullSupplier.inl.
References ACE_GUARD, and consumer_i().
00037 { 00038 ACE_GUARD (ACE_Lock, ace_mon, *this->lock_); 00039 00040 this->consumer_i (consumer); 00041 }
ACE_INLINE CosEventComm::PullConsumer_ptr TAO_CEC_ProxyPullSupplier::consumer | ( | void | ) | const |
Return the consumer object reference. It returns nil() if it has not connected yet. NOTE: This method does not return a new reference!!! Doing so will increase the locking overhead on the critical path.
Definition at line 22 of file CEC_ProxyPullSupplier.inl.
References ACE_GUARD_RETURN, and consumer_.
Referenced by consumer_non_existent(), disconnect_pull_supplier(), and shutdown().
00023 { 00024 ACE_GUARD_RETURN (ACE_Lock, ace_mon, *this->lock_, 0); 00025 00026 return this->consumer_.in (); 00027 }
ACE_INLINE void TAO_CEC_ProxyPullSupplier::consumer_i | ( | CosEventComm::PullConsumer_ptr | consumer | ) | [protected] |
Definition at line 30 of file CEC_ProxyPullSupplier.inl.
References consumer_.
Referenced by consumer().
CORBA::Boolean TAO_CEC_ProxyPullSupplier::consumer_non_existent | ( | CORBA::Boolean_out | disconnected | ) |
Invoke the _non_existent() pseudo-operation on the consumer. If it is disconnected then it returns true and sets the <disconnected> flag.
Definition at line 113 of file CEC_ProxyPullSupplier.cpp.
References CORBA::Object::_duplicate(), ACE_GUARD_THROW_EX, consumer(), and CORBA::is_nil().
Referenced by TAO_CEC_Ping_Pull_Consumer::work().
00115 { 00116 CORBA::Object_var consumer; 00117 { 00118 ACE_GUARD_THROW_EX ( 00119 ACE_Lock, ace_mon, *this->lock_, 00120 CORBA::INTERNAL ()); 00121 00122 disconnected = 0; 00123 if (this->is_connected_i () == 0) 00124 { 00125 disconnected = 1; 00126 return 0; 00127 } 00128 if (CORBA::is_nil (this->nopolicy_consumer_.in ())) 00129 { 00130 return 0; 00131 } 00132 consumer = CORBA::Object::_duplicate (this->nopolicy_consumer_.in ()); 00133 } 00134 00135 #if (TAO_HAS_MINIMUM_CORBA == 0) 00136 return consumer->_non_existent (); 00137 #else 00138 return 0; 00139 #endif /* TAO_HAS_MINIMUM_CORBA */ 00140 }
void TAO_CEC_ProxyPullSupplier::deactivate | ( | void | ) | [virtual] |
Deactivate from the POA.
Definition at line 61 of file CEC_ProxyPullSupplier.cpp.
References _default_POA().
Referenced by shutdown().
00062 { 00063 try 00064 { 00065 PortableServer::POA_var poa = 00066 this->_default_POA (); 00067 PortableServer::ObjectId_var id = 00068 poa->servant_to_id (this); 00069 poa->deactivate_object (id.in ()); 00070 } 00071 catch (const CORBA::Exception&) 00072 { 00073 // Exceptions here should not be propagated. They usually 00074 // indicate that an object is beign disconnected twice, or some 00075 // race condition, but not a fault that the user needs to know 00076 // about. 00077 } 00078 }
void TAO_CEC_ProxyPullSupplier::disconnect_pull_supplier | ( | void | ) | [virtual] |
Definition at line 299 of file CEC_ProxyPullSupplier.cpp.
References CORBA::Exception::_tao_print_exception(), ACE_GUARD_THROW_EX, cleanup_i(), consumer(), consumer_, TAO_CEC_EventChannel::disconnected(), event_channel_, and CORBA::is_nil().
Referenced by TAO_CEC_Reactive_ConsumerControl::consumer_not_exist().
00300 { 00301 CosEventComm::PullConsumer_var consumer; 00302 00303 { 00304 ACE_GUARD_THROW_EX ( 00305 ACE_Lock, ace_mon, *this->lock_, 00306 CORBA::INTERNAL ()); 00307 // @@ CosEventChannelAdmin::EventChannel::SYNCHRONIZATION_ERROR ()); 00308 00309 if (this->is_connected_i () == 0) 00310 throw CORBA::BAD_INV_ORDER (); 00311 00312 consumer = this->consumer_._retn (); 00313 00314 this->cleanup_i (); 00315 } 00316 00317 // Notify the event channel.... 00318 this->event_channel_->disconnected (this); 00319 00320 if (CORBA::is_nil (consumer.in ())) 00321 return; 00322 00323 if (this->event_channel_->disconnect_callbacks ()) 00324 { 00325 try 00326 { 00327 consumer->disconnect_pull_consumer (); 00328 } 00329 catch (const CORBA::Exception& ex) 00330 { 00331 // Ignore exceptions, we must isolate other clients from 00332 // problems on this one. 00333 ex._tao_print_exception ("ProxySupplier::disconnect_pull_supplier"); 00334 } 00335 } 00336 }
ACE_INLINE CORBA::Boolean TAO_CEC_ProxyPullSupplier::is_connected | ( | void | ) | const |
Return 0 if no consumer is connected...
Definition at line 14 of file CEC_ProxyPullSupplier.inl.
References ACE_GUARD_RETURN, and is_connected_i().
00015 { 00016 ACE_GUARD_RETURN (ACE_Lock, ace_mon, *this->lock_, 0); 00017 00018 return this->is_connected_i (); 00019 }
TAO_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE CORBA::Boolean TAO_CEC_ProxyPullSupplier::is_connected_i | ( | void | ) | const [protected] |
The private version (without locking) of is_connected().
Definition at line 8 of file CEC_ProxyPullSupplier.inl.
References connected_.
Referenced by is_connected().
00009 { 00010 return this->connected_; 00011 }
CORBA::Any * TAO_CEC_ProxyPullSupplier::pull | ( | void | ) | [virtual] |
Definition at line 157 of file CEC_ProxyPullSupplier.cpp.
References ACE_GUARD_RETURN, queue_lock_, and TAO_SYNCH_MUTEX.
00158 { 00159 if (this->is_connected () == 0) 00160 throw CosEventComm::Disconnected (); 00161 00162 ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, ace_mon, queue_lock_, 0); 00163 while (this->queue_.is_empty ()) 00164 { 00165 this->wait_not_empty_.wait (); 00166 } 00167 CORBA::Any any; 00168 if (this->queue_.dequeue_head (any) != 0) 00169 { 00170 throw CORBA::INTERNAL (); 00171 } 00172 return new CORBA::Any (any); 00173 }
void TAO_CEC_ProxyPullSupplier::push | ( | const CORBA::Any & | event | ) |
Push an event into the queue.
Definition at line 143 of file CEC_ProxyPullSupplier.cpp.
References ACE_GUARD, TAO_SYNCH_MUTEX, and wait_not_empty_.
Referenced by TAO_CEC_Propagate_Event_Pull::work().
00144 { 00145 if (this->is_connected () == 0) 00146 return; 00147 00148 ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->queue_lock_); 00149 00150 // Ignore errors 00151 (void) this->queue_.enqueue_tail (event); 00152 00153 this->wait_not_empty_.signal (); 00154 }
void TAO_CEC_ProxyPullSupplier::shutdown | ( | void | ) | [virtual] |
The event channel is shutting down.
Definition at line 81 of file CEC_ProxyPullSupplier.cpp.
References ACE_GUARD_THROW_EX, consumer(), consumer_, deactivate(), and CORBA::is_nil().
00082 { 00083 // Save the consumer we where connected to, we need to send a 00084 // disconnect message to it. 00085 CosEventComm::PullConsumer_var consumer; 00086 00087 { 00088 ACE_GUARD_THROW_EX ( 00089 ACE_Lock, ace_mon, *this->lock_, 00090 CORBA::INTERNAL ()); 00091 // @@ CosEventChannelAdmin::EventChannel::SYNCHRONIZATION_ERROR ()); 00092 00093 consumer = this->consumer_._retn (); 00094 } 00095 00096 this->deactivate (); 00097 00098 if (CORBA::is_nil (consumer.in ())) 00099 return; 00100 00101 try 00102 { 00103 consumer->disconnect_pull_consumer (); 00104 } 00105 catch (const CORBA::Exception&) 00106 { 00107 // Ignore exceptions, we must isolate other clients from 00108 // problems on this one. 00109 } 00110 }
CORBA::Any * TAO_CEC_ProxyPullSupplier::try_pull | ( | CORBA::Boolean_out | has_event | ) | [virtual] |
Definition at line 176 of file CEC_ProxyPullSupplier.cpp.
References ACE_GUARD_RETURN, queue_lock_, and TAO_SYNCH_MUTEX.
00177 { 00178 has_event = 0; 00179 if (this->is_connected () == 0) 00180 throw CosEventComm::Disconnected (); 00181 00182 ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, ace_mon, queue_lock_, 0); 00183 CORBA::Any any; 00184 if (this->queue_.is_empty ()) 00185 { 00186 any <<= CORBA::Long(0); 00187 return new CORBA::Any (any); 00188 } 00189 00190 if (this->queue_.dequeue_head (any) != 0) 00191 { 00192 throw CORBA::INTERNAL (); 00193 } 00194 has_event = 1; 00195 return new CORBA::Any (any); 00196 }
int TAO_CEC_ProxyPullSupplier::connected_ [private] |
If the flag is not zero then we are connected, notice that the consumer can be nil.
Definition at line 151 of file CEC_ProxyPullSupplier.h.
Referenced by cleanup_i(), connect_pull_consumer(), and is_connected_i().
CosEventComm::PullConsumer_var TAO_CEC_ProxyPullSupplier::consumer_ [private] |
The consumer -- use apply_policy() instead of assigning directly to consumer_. This will keep consumer_ and nopolicy_consumer_ in sync.
Definition at line 144 of file CEC_ProxyPullSupplier.h.
Referenced by cleanup_i(), connect_pull_consumer(), consumer(), consumer_i(), disconnect_pull_supplier(), and shutdown().
The Event Channel that owns this object.
Definition at line 132 of file CEC_ProxyPullSupplier.h.
Referenced by _decr_refcnt(), apply_policy(), connect_pull_consumer(), disconnect_pull_supplier(), and ~TAO_CEC_ProxyPullSupplier().
ACE_Lock* TAO_CEC_ProxyPullSupplier::lock_ [private] |
CosEventComm::PullConsumer_var TAO_CEC_ProxyPullSupplier::nopolicy_consumer_ [private] |
The consumer without any policies applied.
Definition at line 147 of file CEC_ProxyPullSupplier.h.
Referenced by apply_policy().
ACE_Unbounded_Queue<CORBA::Any> TAO_CEC_ProxyPullSupplier::queue_ [private] |
Definition at line 159 of file CEC_ProxyPullSupplier.h.
Use a message queue to pass the.
Definition at line 157 of file CEC_ProxyPullSupplier.h.
Referenced by pull(), and try_pull().
The reference count.
Definition at line 140 of file CEC_ProxyPullSupplier.h.
Referenced by _decr_refcnt(), and _incr_refcnt().
Definition at line 134 of file CEC_ProxyPullSupplier.h.