TAO_EC_ProxyPushConsumer_Guard Class Reference

A Guard for the ProxyPushConsumer reference count. More...

#include <EC_ProxyConsumer.h>

Collaboration diagram for TAO_EC_ProxyPushConsumer_Guard:

Collaboration graph
[legend]
List of all members.

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_Filterfilter

Private Attributes

ACE_Locklock_
 The lock used to protect the reference count.

CORBA::ULongrefcount_
 The reference count.

TAO_EC_Event_Channel_Baseevent_channel_
 The event channel used to destroy the proxy.

TAO_EC_ProxyPushConsumerproxy_
 The proxy whose lifetime is controlled by the reference count.

int locked_

Detailed Description

A Guard for the ProxyPushConsumer reference count.

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 & Destructor Documentation

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 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 }

TAO_EC_ProxyPushConsumer_Guard::~TAO_EC_ProxyPushConsumer_Guard void   ) 
 

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 }


Member Function Documentation

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.i.

References locked_.

00067 {
00068   return this->locked_;
00069 }


Member Data Documentation

TAO_EC_Event_Channel_Base* TAO_EC_ProxyPushConsumer_Guard::event_channel_ [private]
 

The event channel used to destroy the proxy.

Definition at line 220 of file EC_ProxyConsumer.h.

TAO_EC_Supplier_Filter* TAO_EC_ProxyPushConsumer_Guard::filter
 

Definition at line 210 of file EC_ProxyConsumer.h.

Referenced by TAO_EC_ProxyPushConsumer_Guard(), and ~TAO_EC_ProxyPushConsumer_Guard().

ACE_Lock* TAO_EC_ProxyPushConsumer_Guard::lock_ [private]
 

The lock used to protect the reference count.

Definition at line 214 of file EC_ProxyConsumer.h.

int TAO_EC_ProxyPushConsumer_Guard::locked_ [private]
 

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().

TAO_EC_ProxyPushConsumer* TAO_EC_ProxyPushConsumer_Guard::proxy_ [private]
 

The proxy whose lifetime is controlled by the reference count.

Definition at line 223 of file EC_ProxyConsumer.h.

CORBA::ULong& TAO_EC_ProxyPushConsumer_Guard::refcount_ [private]
 

The reference count.

Definition at line 217 of file EC_ProxyConsumer.h.


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 13:15:19 2006 for TAO_RTEvent by doxygen 1.3.6