#include <ESF_Proxy_RefCount_Guard.h>
Collaboration diagram for TAO_ESF_Proxy_RefCount_Guard< EVENT_CHANNEL, PROXY >:
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::ULong & | refcount_ |
EVENT_CHANNEL * | event_channel_ |
The event channel used to destroy the proxy. | |
PROXY * | proxy_ |
The proxy whose lifetime is controlled by the reference count. |
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.
: The type of lock could be parametric
Definition at line 42 of file ESF_Proxy_RefCount_Guard.h.
|
Constructor.
Definition at line 9 of file ESF_Proxy_RefCount_Guard.i.
00012 : refcount_ (refcount), 00013 event_channel_ (ec), 00014 proxy_ (proxy) 00015 { 00016 } |
|
Destructor.
Definition at line 15 of file ESF_Proxy_RefCount_Guard.cpp.
00016 { 00017 // Checking for 0 is safe, once the variable reaches 0 the value 00018 // will stay there. 00019 // @@ But what if the thread is switched to another processor just 00020 // after release the mutex? 00021 if (this->refcount_ == 0) 00022 { 00023 this->event_channel_->destroy_proxy (this->proxy_); 00024 } 00025 } |
|
The event channel used to destroy the proxy.
Definition at line 59 of file ESF_Proxy_RefCount_Guard.h. |
|
The proxy whose lifetime is controlled by the reference count.
Definition at line 62 of file ESF_Proxy_RefCount_Guard.h. |
|
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. |