Public Member Functions | Protected Attributes

TAO_ESF_Proxy_RefCount_Guard< EVENT_CHANNEL, PROXY > Class Template Reference

Reference count based guard. More...

#include <ESF_Proxy_RefCount_Guard.h>

List of all members.

Public Member Functions

 TAO_ESF_Proxy_RefCount_Guard (CORBA::ULong &refcount, EVENT_CHANNEL *ec, PROXY *proxy)
 Constructor.
 ~TAO_ESF_Proxy_RefCount_Guard (void)
 Destructor.

Protected Attributes

CORBA::ULongrefcount_
EVENT_CHANNEL * event_channel_
 The event channel used to destroy the proxy.
PROXY * proxy_
 The proxy whose lifetime is controlled by the reference count.

Detailed Description

template<class EVENT_CHANNEL, class PROXY>
class TAO_ESF_Proxy_RefCount_Guard< EVENT_CHANNEL, PROXY >

Reference count based guard.

A common idiom used on event services is to increment a reference count before starting a long running operation. The system can then execute the operation without any risk of having the underlying object destroyed. The advantage of using a reference count is that no mutex or lock needs to be held while the operation is beign executed. This class implements that common idiom, but it also adds hooks to handle scenarios where more than one operation is performed while holding the reference count.

Todo:
The type of lock could be parametric

Definition at line 42 of file ESF_Proxy_RefCount_Guard.h.


Constructor & Destructor Documentation

template<class EVENT_CHANNEL , class PROXY >
TAO_ESF_Proxy_RefCount_Guard< EVENT_CHANNEL, PROXY >::TAO_ESF_Proxy_RefCount_Guard ( CORBA::ULong refcount,
EVENT_CHANNEL *  ec,
PROXY *  proxy 
)

Constructor.

template<class EC , class P >
TAO_ESF_Proxy_RefCount_Guard< EC, P >::~TAO_ESF_Proxy_RefCount_Guard ( void   ) 

Destructor.

Definition at line 15 of file ESF_Proxy_RefCount_Guard.cpp.

{
  // Checking for 0 is safe, once the variable reaches 0 the value
  // will stay there.
  // @@ But what if the thread is switched to another processor just
  // after release the mutex?
  if (this->refcount_ == 0)
    {
      this->event_channel_->destroy_proxy (this->proxy_);
    }
}


Member Data Documentation

template<class EVENT_CHANNEL , class PROXY >
EVENT_CHANNEL* TAO_ESF_Proxy_RefCount_Guard< EVENT_CHANNEL, PROXY >::event_channel_ [protected]

The event channel used to destroy the proxy.

Definition at line 59 of file ESF_Proxy_RefCount_Guard.h.

template<class EVENT_CHANNEL , class PROXY >
PROXY* TAO_ESF_Proxy_RefCount_Guard< EVENT_CHANNEL, PROXY >::proxy_ [protected]

The proxy whose lifetime is controlled by the reference count.

Definition at line 62 of file ESF_Proxy_RefCount_Guard.h.

template<class EVENT_CHANNEL , class PROXY >
CORBA::ULong& TAO_ESF_Proxy_RefCount_Guard< EVENT_CHANNEL, PROXY >::refcount_ [protected]

The reference count, if it gets to zero then the object must be destroyed

Definition at line 56 of file ESF_Proxy_RefCount_Guard.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Defines