#include <CEC_ProxyPushConsumer.h>
Collaboration diagram for TAO_CEC_ProxyPushConsumer_Guard:
Public Member Functions | |
TAO_CEC_ProxyPushConsumer_Guard (ACE_Lock *lock, CORBA::ULong &refcount, TAO_CEC_EventChannel *ec, TAO_CEC_ProxyPushConsumer *proxy) | |
Constructor. | |
~TAO_CEC_ProxyPushConsumer_Guard (void) | |
Destructor. | |
bool | locked (void) const |
Returns true if the reference count successfully acquired. | |
Private Attributes | |
ACE_Lock * | lock_ |
The lock used to protect the reference count. | |
CORBA::ULong & | refcount_ |
The reference count. | |
TAO_CEC_EventChannel * | event_channel_ |
The event channel used to destroy the proxy. | |
TAO_CEC_ProxyPushConsumer * | proxy_ |
The proxy whose lifetime is controlled by the reference count. | |
bool | locked_ |
This is a helper class used in the implementation of ProxyPushConumer. It provides a Guard mechanism to increment the reference count on the proxy, eliminating the need to hold mutexes during long operations.
Definition at line 157 of file CEC_ProxyPushConsumer.h.
|
Constructor.
Definition at line 319 of file CEC_ProxyPushConsumer.cpp. References TAO_CEC_ProxyPushConsumer::is_connected_i(), and locked_.
00323 : lock_ (lock), 00324 refcount_ (refcount), 00325 event_channel_ (ec), 00326 proxy_ (proxy), 00327 locked_ (false) 00328 { 00329 ACE_Guard<ACE_Lock> ace_mon (*this->lock_); 00330 // If the guard fails there is not much we can do, raising an 00331 // exception is wrong, the client has *no* way to handle that kind 00332 // of error. Even worse, there is no exception to raise in that 00333 // case. 00334 // @@ Returning something won't work either, the error should be 00335 // logged though! 00336 00337 if (!proxy->is_connected_i ()) 00338 return; 00339 00340 this->locked_ = true; 00341 ++this->refcount_; 00342 } |
|
Destructor.
Definition at line 345 of file CEC_ProxyPushConsumer.cpp. References TAO_CEC_EventChannel::destroy_proxy(), and locked_.
00346 { 00347 // This access is safe because guard objects are created on the 00348 // stack, only one thread has access to them 00349 if (!this->locked_) 00350 return; 00351 00352 { 00353 ACE_Guard<ACE_Lock> ace_mon (*this->lock_); 00354 // If the guard fails there is not much we can do, raising an 00355 // exception is wrong, the client has *no* way to handle that kind 00356 // of error. Even worse, there is no exception to raise in that 00357 // case. 00358 // @@ Returning something won't work either, the error should be 00359 // logged though! 00360 00361 --this->refcount_; 00362 if (this->refcount_ != 0) 00363 return; 00364 } 00365 this->event_channel_->destroy_proxy (this->proxy_); 00366 } |
|
Returns true if the reference count successfully acquired.
Definition at line 45 of file CEC_ProxyPushConsumer.i. References locked_.
00046 { 00047 return this->locked_; 00048 } |
|
The event channel used to destroy the proxy.
Definition at line 180 of file CEC_ProxyPushConsumer.h. |
|
The lock used to protect the reference count.
Definition at line 174 of file CEC_ProxyPushConsumer.h. |
|
This flag is set to true if the reference count was successfully acquired. Definition at line 187 of file CEC_ProxyPushConsumer.h. Referenced by locked(), TAO_CEC_ProxyPushConsumer_Guard(), and ~TAO_CEC_ProxyPushConsumer_Guard(). |
|
The proxy whose lifetime is controlled by the reference count.
Definition at line 183 of file CEC_ProxyPushConsumer.h. |
|
The reference count.
Definition at line 177 of file CEC_ProxyPushConsumer.h. |