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 159 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 317 of file CEC_ProxyPushConsumer.cpp.

References TAO_CEC_ProxyPushConsumer::is_connected_i(), locked_, and refcount_.

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

TAO_CEC_ProxyPushConsumer_Guard::~TAO_CEC_ProxyPushConsumer_Guard ( void   ) 

Destructor.

Definition at line 343 of file CEC_ProxyPushConsumer.cpp.

References TAO_CEC_EventChannel::destroy_proxy(), event_channel_, and refcount_.

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


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

References locked_.

Referenced by TAO_CEC_ProxyPushConsumer::push().

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 182 of file CEC_ProxyPushConsumer.h.

Referenced by ~TAO_CEC_ProxyPushConsumer_Guard().

ACE_Lock* TAO_CEC_ProxyPushConsumer_Guard::lock_ [private]

The lock used to protect the reference count.

Definition at line 176 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 189 of file CEC_ProxyPushConsumer.h.

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

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

The reference count.

Definition at line 179 of file CEC_ProxyPushConsumer.h.

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


The documentation for this class was generated from the following files:
Generated on Tue Feb 2 17:45:00 2010 for TAO_CosEvent by  doxygen 1.4.7