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


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


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 211 of file EC_ProxyConsumer.h.

TAO_EC_Supplier_Filter* TAO_EC_ProxyPushConsumer_Guard::filter

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]

The lock used to protect the reference count.

Definition at line 205 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 218 of file EC_ProxyConsumer.h.

Referenced by locked(), 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 214 of file EC_ProxyConsumer.h.

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

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

The reference count.

Definition at line 208 of file EC_ProxyConsumer.h.

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


The documentation for this class was generated from the following files:
Generated on Tue Feb 2 17:44:32 2010 for TAO_RTEvent by  doxygen 1.4.7