TAO_CEC_ProxyPushConsumer_Guard Class Reference

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

#include <CEC_ProxyPushConsumer.h>

Collaboration diagram for TAO_CEC_ProxyPushConsumer_Guard:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 TAO_CEC_ProxyPushConsumer_Guard (ACE_Lock *lock, CORBA::ULong &refcount, TAO_CEC_EventChannel *ec, TAO_CEC_ProxyPushConsumer *proxy)
 Constructor.

 ~TAO_CEC_ProxyPushConsumer_Guard (void)
 Destructor.

bool locked (void) const
 Returns true if the reference count successfully acquired.


Private Attributes

ACE_Locklock_
 The lock used to protect the reference count.

CORBA::ULongrefcount_
 The reference count.

TAO_CEC_EventChannelevent_channel_
 The event channel used to destroy the proxy.

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

bool 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, eliminating the need to hold mutexes during long operations.

Definition at line 157 of file CEC_ProxyPushConsumer.h.


Constructor & Destructor Documentation

TAO_CEC_ProxyPushConsumer_Guard::TAO_CEC_ProxyPushConsumer_Guard ACE_Lock lock,
CORBA::ULong refcount,
TAO_CEC_EventChannel ec,
TAO_CEC_ProxyPushConsumer proxy
 

Constructor.

Definition at line 319 of file CEC_ProxyPushConsumer.cpp.

References TAO_CEC_ProxyPushConsumer::is_connected_i(), and locked_.

00323  :   lock_ (lock),
00324      refcount_ (refcount),
00325      event_channel_ (ec),
00326      proxy_ (proxy),
00327      locked_ (false)
00328 {
00329   ACE_Guard<ACE_Lock> ace_mon (*this->lock_);
00330   // If the guard fails there is not much we can do, raising an
00331   // exception is wrong, the client has *no* way to handle that kind
00332   // of error.  Even worse, there is no exception to raise in that
00333   // case.
00334   // @@ Returning something won't work either, the error should be
00335   // logged though!
00336 
00337   if (!proxy->is_connected_i ())
00338     return;
00339 
00340   this->locked_ = true;
00341   ++this->refcount_;
00342 }

TAO_CEC_ProxyPushConsumer_Guard::~TAO_CEC_ProxyPushConsumer_Guard void   ) 
 

Destructor.

Definition at line 345 of file CEC_ProxyPushConsumer.cpp.

References TAO_CEC_EventChannel::destroy_proxy(), and locked_.

00346 {
00347   // This access is safe because guard objects are created on the
00348   // stack, only one thread has access to them
00349   if (!this->locked_)
00350     return;
00351 
00352   {
00353     ACE_Guard<ACE_Lock> ace_mon (*this->lock_);
00354     // If the guard fails there is not much we can do, raising an
00355     // exception is wrong, the client has *no* way to handle that kind
00356     // of error.  Even worse, there is no exception to raise in that
00357     // case.
00358     // @@ Returning something won't work either, the error should be
00359     // logged though!
00360 
00361     --this->refcount_;
00362     if (this->refcount_ != 0)
00363       return;
00364   }
00365   this->event_channel_->destroy_proxy (this->proxy_);
00366 }


Member Function Documentation

ACE_INLINE bool TAO_CEC_ProxyPushConsumer_Guard::locked void   )  const
 

Returns true if the reference count successfully acquired.

Definition at line 45 of file CEC_ProxyPushConsumer.i.

References locked_.

00046 {
00047   return this->locked_;
00048 }


Member Data Documentation

TAO_CEC_EventChannel* TAO_CEC_ProxyPushConsumer_Guard::event_channel_ [private]
 

The event channel used to destroy the proxy.

Definition at line 180 of file CEC_ProxyPushConsumer.h.

ACE_Lock* TAO_CEC_ProxyPushConsumer_Guard::lock_ [private]
 

The lock used to protect the reference count.

Definition at line 174 of file CEC_ProxyPushConsumer.h.

bool TAO_CEC_ProxyPushConsumer_Guard::locked_ [private]
 

This flag is set to true if the reference count was successfully acquired.

Definition at line 187 of file CEC_ProxyPushConsumer.h.

Referenced by locked(), TAO_CEC_ProxyPushConsumer_Guard(), and ~TAO_CEC_ProxyPushConsumer_Guard().

TAO_CEC_ProxyPushConsumer* TAO_CEC_ProxyPushConsumer_Guard::proxy_ [private]
 

The proxy whose lifetime is controlled by the reference count.

Definition at line 183 of file CEC_ProxyPushConsumer.h.

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

The reference count.

Definition at line 177 of file CEC_ProxyPushConsumer.h.


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