#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 195 of file EC_ProxyConsumer.h.
|
Constructor.
Definition at line 255 of file EC_ProxyConsumer.cpp. References TAO_EC_Supplier_Filter::_incr_refcnt(), filter, TAO_EC_ProxyPushConsumer::filter_i(), TAO_EC_ProxyPushConsumer::is_connected_i(), and locked_.
00259 : lock_ (lock), 00260 refcount_ (refcount), 00261 event_channel_ (ec), 00262 proxy_ (proxy), 00263 locked_ (0) 00264 { 00265 ACE_Guard<ACE_Lock> ace_mon (*this->lock_); 00266 // If the guard fails there is not much we can do, raising an 00267 // exception is wrong, the client has *no* way to handle that kind 00268 // of error. Even worse, there is no exception to raise in that 00269 // case. 00270 // @@ Returning something won't work either, the error should be 00271 // logged though! 00272 00273 if (proxy->is_connected_i () == 0) 00274 return; 00275 00276 this->filter = this->proxy_->filter_i (); 00277 this->filter->_incr_refcnt (); 00278 00279 this->locked_ = 1; 00280 this->refcount_++; 00281 } |
|
Destructor.
Definition at line 284 of file EC_ProxyConsumer.cpp. References TAO_EC_Supplier_Filter::_decr_refcnt(), filter, locked_, and TAO_EC_ProxyPushConsumer::refcount_zero_hook().
00285 { 00286 // This access is safe because guard objects are created on the 00287 // stack, only one thread has access to them 00288 if (!this->locked_) 00289 return; 00290 00291 { 00292 ACE_Guard<ACE_Lock> ace_mon (*this->lock_); 00293 // If the guard fails there is not much we can do, raising an 00294 // exception is wrong, the client has *no* way to handle that kind 00295 // of error. Even worse, there is no exception to raise in that 00296 // case. 00297 // @@ Returning something won't work either, the error should be 00298 // logged though! 00299 00300 this->filter->_decr_refcnt (); 00301 00302 this->refcount_--; 00303 if (this->refcount_ != 0) 00304 return; 00305 } 00306 00307 this->proxy_->refcount_zero_hook (); 00308 } |
|
Returns 1 if the reference count successfully acquired.
Definition at line 66 of file EC_ProxyConsumer.i. References locked_.
00067 { 00068 return this->locked_; 00069 } |
|
The event channel used to destroy the proxy.
Definition at line 220 of file EC_ProxyConsumer.h. |
|
Definition at line 210 of file EC_ProxyConsumer.h. Referenced by TAO_EC_ProxyPushConsumer_Guard(), and ~TAO_EC_ProxyPushConsumer_Guard(). |
|
The lock used to protect the reference count.
Definition at line 214 of file EC_ProxyConsumer.h. |
|
This flag is set to 1 if the reference count was successfully acquired. Definition at line 227 of file EC_ProxyConsumer.h. Referenced by locked(), TAO_EC_ProxyPushConsumer_Guard(), and ~TAO_EC_ProxyPushConsumer_Guard(). |
|
The proxy whose lifetime is controlled by the reference count.
Definition at line 223 of file EC_ProxyConsumer.h. |
|
The reference count.
Definition at line 217 of file EC_ProxyConsumer.h. |