#include <CEC_TypedProxyPushConsumer.h>
Collaboration diagram for TAO_CEC_TypedProxyPushConsumer_Guard:
Public Member Functions | |
TAO_CEC_TypedProxyPushConsumer_Guard (ACE_Lock *lock, CORBA::ULong &refcount, TAO_CEC_TypedEventChannel *ec, TAO_CEC_TypedProxyPushConsumer *proxy) | |
Constructor. | |
~TAO_CEC_TypedProxyPushConsumer_Guard (void) | |
Destructor. | |
int | locked (void) const |
Returns 1 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_TypedEventChannel * | typed_event_channel_ |
The event channel used to destroy the proxy. | |
TAO_CEC_TypedProxyPushConsumer * | proxy_ |
The proxy whose lifetime is controlled by the reference count. | |
int | locked_ |
This is a helper class used in the implementation of TypedProxyPushConumer. 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 153 of file CEC_TypedProxyPushConsumer.h.
TAO_CEC_TypedProxyPushConsumer_Guard::TAO_CEC_TypedProxyPushConsumer_Guard | ( | ACE_Lock * | lock, | |
CORBA::ULong & | refcount, | |||
TAO_CEC_TypedEventChannel * | ec, | |||
TAO_CEC_TypedProxyPushConsumer * | proxy | |||
) |
Constructor.
Definition at line 361 of file CEC_TypedProxyPushConsumer.cpp.
References TAO_CEC_TypedProxyPushConsumer::is_connected_i(), locked_, and refcount_.
00365 : lock_ (lock), 00366 refcount_ (refcount), 00367 typed_event_channel_ (ec), 00368 proxy_ (proxy), 00369 locked_ (0) 00370 { 00371 ACE_Guard<ACE_Lock> ace_mon (*this->lock_); 00372 // If the guard fails there is not much we can do, raising an 00373 // exception is wrong, the client has *no* way to handle that kind 00374 // of error. Even worse, there is no exception to raise in that 00375 // case. 00376 // @@ Returning something won't work either, the error should be 00377 // logged though! 00378 00379 if (proxy->is_connected_i () == 0) 00380 return; 00381 00382 this->locked_ = 1; 00383 this->refcount_++; 00384 }
TAO_CEC_TypedProxyPushConsumer_Guard::~TAO_CEC_TypedProxyPushConsumer_Guard | ( | void | ) |
Destructor.
Definition at line 387 of file CEC_TypedProxyPushConsumer.cpp.
References TAO_CEC_TypedEventChannel::destroy_proxy(), refcount_, and typed_event_channel_.
00388 { 00389 // This access is safe because guard objects are created on the 00390 // stack, only one thread has access to them 00391 if (!this->locked_) 00392 return; 00393 00394 { 00395 ACE_Guard<ACE_Lock> ace_mon (*this->lock_); 00396 // If the guard fails there is not much we can do, raising an 00397 // exception is wrong, the client has *no* way to handle that kind 00398 // of error. Even worse, there is no exception to raise in that 00399 // case. 00400 // @@ Returning something won't work either, the error should be 00401 // logged though! 00402 00403 this->refcount_--; 00404 if (this->refcount_ != 0) 00405 return; 00406 } 00407 this->typed_event_channel_->destroy_proxy (this->proxy_); 00408 }
ACE_INLINE int TAO_CEC_TypedProxyPushConsumer_Guard::locked | ( | void | ) | const |
Returns 1 if the reference count successfully acquired.
Definition at line 16 of file CEC_TypedProxyPushConsumer.inl.
References locked_.
Referenced by TAO_CEC_TypedProxyPushConsumer::invoke().
00017 { 00018 return this->locked_; 00019 }
The lock used to protect the reference count.
Definition at line 172 of file CEC_TypedProxyPushConsumer.h.
int TAO_CEC_TypedProxyPushConsumer_Guard::locked_ [private] |
This flag is set to 1 if the reference count was successfully acquired.
Definition at line 185 of file CEC_TypedProxyPushConsumer.h.
Referenced by locked(), and TAO_CEC_TypedProxyPushConsumer_Guard().
The proxy whose lifetime is controlled by the reference count.
Definition at line 181 of file CEC_TypedProxyPushConsumer.h.
The reference count.
Definition at line 175 of file CEC_TypedProxyPushConsumer.h.
Referenced by TAO_CEC_TypedProxyPushConsumer_Guard(), and ~TAO_CEC_TypedProxyPushConsumer_Guard().
The event channel used to destroy the proxy.
Definition at line 178 of file CEC_TypedProxyPushConsumer.h.
Referenced by ~TAO_CEC_TypedProxyPushConsumer_Guard().