ESF_Proxy_RefCount_Guard.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 /**
00004  *  @file   ESF_Proxy_RefCount_Guard.h
00005  *
00006  *  ESF_Proxy_RefCount_Guard.h,v 1.7 2006/03/15 07:52:21 jtc Exp
00007  *
00008  *  @author Carlos O'Ryan (coryan@cs.wustl.edu)
00009  *
00010  *  http://doc.ece.uci.edu/~coryan/EC/index.html
00011  */
00012 
00013 #ifndef TAO_ESF_PROXY_REFCOUNT_GUARD_H
00014 #define TAO_ESF_PROXY_REFCOUNT_GUARD_H
00015 
00016 #include "tao/Basic_Types.h"
00017 
00018 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00019 # pragma once
00020 #endif /* ACE_LACKS_PRAGMA_ONCE */
00021 
00022 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00023 
00024 /**
00025  * @class TAO_ESF_Proxy_RefCount_Guard
00026  *
00027  * @brief Reference count based guard.
00028  *
00029  * A common idiom used on event services is to increment a
00030  * reference count before starting a long running operation.
00031  * The system can then execute the operation without any risk of
00032  * having the underlying object destroyed.  The advantage of using
00033  * a reference count is that no mutex or lock needs to be held
00034  * while the operation is beign executed.
00035  * This class implements that common idiom, but it also adds hooks
00036  * to handle scenarios where more than one operation is performed
00037  * while holding the reference count.
00038  *
00039  * @TODO: The type of lock could be parametric
00040  */
00041 template<class EVENT_CHANNEL, class PROXY>
00042 class TAO_ESF_Proxy_RefCount_Guard
00043 {
00044 public:
00045   /// Constructor
00046   TAO_ESF_Proxy_RefCount_Guard (CORBA::ULong &refcount,
00047                                 EVENT_CHANNEL *ec,
00048                                 PROXY *proxy);
00049 
00050   /// Destructor
00051   ~TAO_ESF_Proxy_RefCount_Guard (void);
00052 
00053 protected:
00054   /// The reference count, if it gets to zero then the object must be
00055   /// destroyed
00056   CORBA::ULong &refcount_;
00057 
00058   /// The event channel used to destroy the proxy
00059   EVENT_CHANNEL *event_channel_;
00060 
00061   /// The proxy whose lifetime is controlled by the reference count
00062   PROXY *proxy_;
00063 };
00064 
00065 TAO_END_VERSIONED_NAMESPACE_DECL
00066 
00067 #if defined (__ACE_INLINE__)
00068 #include "orbsvcs/ESF/ESF_Proxy_RefCount_Guard.i"
00069 #endif /* __ACE_INLINE__ */
00070 
00071 #if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
00072 #include "orbsvcs/ESF/ESF_Proxy_RefCount_Guard.cpp"
00073 #endif /* ACE_TEMPLATES_REQUIRE_SOURCE */
00074 
00075 #if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
00076 #pragma implementation ("ESF_Proxy_RefCount_Guard.cpp")
00077 #endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */
00078 
00079 #endif /* TAO_ESF_PROXY_REFCOUNT_GUARD_H */

Generated on Thu Nov 9 13:08:14 2006 for TAO_ESF by doxygen 1.3.6