#include <EC_ProxyConsumer.h>
Collaboration diagram for TAO_EC_ProxyPushConsumer_Guard:
Public Member Functions | |
TAO_EC_ProxyPushConsumer_Guard (ACE_Lock *lock, CORBA::ULong &refcount, TAO_EC_Event_Channel_Base *ec, TAO_EC_ProxyPushConsumer *proxy) | |
Constructor. | |
~TAO_EC_ProxyPushConsumer_Guard (void) | |
Destructor. | |
int | locked (void) const |
Returns 1 if the reference count successfully acquired. | |
Public Attributes | |
TAO_EC_Supplier_Filter * | filter |
Private Attributes | |
ACE_Lock * | lock_ |
The lock used to protect the reference count. | |
CORBA::ULong & | refcount_ |
The reference count. | |
TAO_EC_Event_Channel_Base * | event_channel_ |
The event channel used to destroy the proxy. | |
TAO_EC_ProxyPushConsumer * | proxy_ |
The proxy whose lifetime is controlled by the reference count. | |
int | 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 and its filter, eliminating the need to hold mutexes during long operations.
Definition at line 186 of file EC_ProxyConsumer.h.
TAO_EC_ProxyPushConsumer_Guard::TAO_EC_ProxyPushConsumer_Guard | ( | ACE_Lock * | lock, | |
CORBA::ULong & | refcount, | |||
TAO_EC_Event_Channel_Base * | ec, | |||
TAO_EC_ProxyPushConsumer * | proxy | |||
) |
Constructor.
Definition at line 238 of file EC_ProxyConsumer.cpp.
References TAO_EC_Supplier_Filter::_incr_refcnt(), filter, TAO_EC_ProxyPushConsumer::filter_i(), TAO_EC_ProxyPushConsumer::is_connected_i(), locked_, proxy_, and refcount_.
00242 : lock_ (lock), 00243 refcount_ (refcount), 00244 event_channel_ (ec), 00245 proxy_ (proxy), 00246 locked_ (0) 00247 { 00248 ACE_Guard<ACE_Lock> ace_mon (*this->lock_); 00249 // If the guard fails there is not much we can do, raising an 00250 // exception is wrong, the client has *no* way to handle that kind 00251 // of error. Even worse, there is no exception to raise in that 00252 // case. 00253 // @@ Returning something won't work either, the error should be 00254 // logged though! 00255 00256 if (proxy->is_connected_i () == 0) 00257 return; 00258 00259 this->filter = this->proxy_->filter_i (); 00260 this->filter->_incr_refcnt (); 00261 00262 this->locked_ = 1; 00263 this->refcount_++; 00264 }
TAO_EC_ProxyPushConsumer_Guard::~TAO_EC_ProxyPushConsumer_Guard | ( | void | ) |
Destructor.
Definition at line 267 of file EC_ProxyConsumer.cpp.
References TAO_EC_Supplier_Filter::_decr_refcnt(), filter, proxy_, refcount_, and TAO_EC_ProxyPushConsumer::refcount_zero_hook().
00268 { 00269 // This access is safe because guard objects are created on the 00270 // stack, only one thread has access to them 00271 if (!this->locked_) 00272 return; 00273 00274 { 00275 ACE_Guard<ACE_Lock> ace_mon (*this->lock_); 00276 // If the guard fails there is not much we can do, raising an 00277 // exception is wrong, the client has *no* way to handle that kind 00278 // of error. Even worse, there is no exception to raise in that 00279 // case. 00280 // @@ Returning something won't work either, the error should be 00281 // logged though! 00282 00283 this->filter->_decr_refcnt (); 00284 00285 this->refcount_--; 00286 if (this->refcount_ != 0) 00287 return; 00288 } 00289 00290 this->proxy_->refcount_zero_hook (); 00291 }
ACE_INLINE int TAO_EC_ProxyPushConsumer_Guard::locked | ( | void | ) | const |
Returns 1 if the reference count successfully acquired.
Definition at line 66 of file EC_ProxyConsumer.inl.
References locked_.
Referenced by TAO_EC_ProxyPushConsumer::connected(), TAO_EC_ProxyPushConsumer::disconnected(), TAO_EC_Default_ProxyPushConsumer::push(), and TAO_EC_ProxyPushConsumer::reconnected().
00067 { 00068 return this->locked_; 00069 }
Definition at line 201 of file EC_ProxyConsumer.h.
Referenced by TAO_EC_ProxyPushConsumer::connected(), TAO_EC_ProxyPushConsumer::disconnected(), TAO_EC_Default_ProxyPushConsumer::push(), TAO_EC_ProxyPushConsumer::reconnected(), TAO_EC_ProxyPushConsumer_Guard(), and ~TAO_EC_ProxyPushConsumer_Guard().
ACE_Lock* TAO_EC_ProxyPushConsumer_Guard::lock_ [private] |
int TAO_EC_ProxyPushConsumer_Guard::locked_ [private] |
This flag is set to 1 if the reference count was successfully acquired.
Definition at line 218 of file EC_ProxyConsumer.h.
Referenced by locked(), and TAO_EC_ProxyPushConsumer_Guard().
The proxy whose lifetime is controlled by the reference count.
Definition at line 214 of file EC_ProxyConsumer.h.
Referenced by TAO_EC_ProxyPushConsumer_Guard(), and ~TAO_EC_ProxyPushConsumer_Guard().
The reference count.
Definition at line 208 of file EC_ProxyConsumer.h.
Referenced by TAO_EC_ProxyPushConsumer_Guard(), and ~TAO_EC_ProxyPushConsumer_Guard().