#include <Refcountable.h>
Inheritance diagram for TAO_Notify_Refcountable:
Public Types | |
typedef TAO_Notify_Refcountable_Guard_T< TAO_Notify_Refcountable > | Ptr |
Public Member Functions | |
TAO_Notify_Refcountable (void) | |
Constructor. | |
virtual | ~TAO_Notify_Refcountable () |
CORBA::ULong | _incr_refcnt (void) |
CORBA::ULong | _decr_refcnt (void) |
Private Member Functions | |
virtual void | release (void)=0 |
The release method is called when the refcount reaches 0. | |
Private Attributes | |
ACE_Atomic_Op< TAO_SYNCH_MUTEX, CORBA::Long > | refcount_ |
The refcount is initialized to 0. When an instance of a derived class becomes owned by a managed pointer (Refcountable_Guard_T) the reference count becomes non-zero.
Instances declared on the stack should always have a refcount of zero.
A method that creates or simply returns an instance of Refcountable should not increment the reference count. It is the responsibility of the client to increment the reference count (take ownership or guard against deletion). The client cannot know if the method will or will not incr the refcount on its behalf.
Use Refcountable_Guard_T or similar service to guarantee the exception safe direct pairing of increments and decrements. Avoid calling _incr_refcnt and _decr_refcnt.
Definition at line 60 of file Refcountable.h.
|
|
Constructor.
Definition at line 70 of file Refcountable.cpp.
00071 { 00072 } |
|
Destructor public for stack allocated instances Definition at line 74 of file Refcountable.cpp. References ACE_ASSERT, ACE_DEBUG, and LM_DEBUG.
00075 { 00076 #if ( TAO_NOTIFY_REFCOUNT_DIAGNOSTICS != 0 ) 00077 TAO_Notify_Tracker::Entry e = TAO_Notify_Tracker::get_instance().find( this ); 00078 if ( e.obj != 0 ) 00079 { 00080 ACE_DEBUG ((LM_DEBUG,"object:%x %s(%d) with refcount:%d destroyed incorrectly.\n", 00081 e.obj, e.class_name, e.obj->ref_id_, e.obj->refcount_.value() )); 00082 00083 if ( e.obj != this || e.obj->ref_id_ != this->ref_id_ ) 00084 { 00085 ACE_DEBUG ((LM_DEBUG, " with an ID mismatch %x->%d != %x->%d!\n", 00086 this, ref_id_, e.obj, e.obj->ref_id_)); 00087 } 00088 TAO_Notify_Tracker::get_instance().remove( this ); 00089 } 00090 #endif 00091 CORBA::ULong refcount = this->refcount_.value(); 00092 ACE_ASSERT( refcount == 0 ); 00093 ACE_UNUSED_ARG(refcount); 00094 } |
|
Definition at line 118 of file Refcountable.cpp. References ACE_ASSERT, ACE_DEBUG, LM_DEBUG, release(), and TAO_debug_level. Referenced by TAO_Notify_Peer::_decr_refcnt(), TAO_Notify_SupplierAdmin::_remove_ref(), TAO_Notify_Proxy_T< SERVANT_TYPE >::_remove_ref(), TAO_Notify_EventChannelFactory::_remove_ref(), TAO_Notify_EventChannel::_remove_ref(), TAO_Notify_ConsumerAdmin::_remove_ref(), TAO_Notify_ThreadPool_Task::close(), and TAO_Notify_ThreadPool_Task::init().
00119 { 00120 CORBA::Long refcount = --this->refcount_; 00121 00122 if (TAO_debug_level > 1 ) 00123 { 00124 ACE_DEBUG ((LM_DEBUG,"object:%x decr refcount = %d\n", this, refcount )); 00125 } 00126 00127 ACE_ASSERT(refcount >= 0); 00128 00129 if (refcount == 0) 00130 { 00131 #if ( USE_TAO_NOTIFY_TRACKER != 0 ) 00132 TAO_Notify_Tracker::get_instance().remove( this ); 00133 #endif 00134 this->release (); 00135 } 00136 return refcount; 00137 } |
|
This method sigantures deliberately match the RefCounting methods required for ESF Proxy Public for bridge implementations and various guard classes Definition at line 98 of file Refcountable.cpp. References ACE_DEBUG, LM_DEBUG, and TAO_debug_level. Referenced by TAO_Notify_SupplierAdmin::_add_ref(), TAO_Notify_Proxy_T< SERVANT_TYPE >::_add_ref(), TAO_Notify_EventChannelFactory::_add_ref(), TAO_Notify_EventChannel::_add_ref(), TAO_Notify_ConsumerAdmin::_add_ref(), TAO_Notify_Peer::_incr_refcnt(), TAO_Notify_ThreadPool_Task::init(), and TAO_Notify_Proxy_T< SERVANT_TYPE >::TAO_Notify_Proxy_T().
00099 { 00100 CORBA::Long refcount = ++this->refcount_; 00101 if (TAO_debug_level > 1 ) 00102 { 00103 ACE_DEBUG ((LM_DEBUG,"object:%x incr refcount = %d\n", this, refcount )); 00104 } 00105 #if ( TAO_NOTIFY_REFCOUNT_DIAGNOSTICS != 0 ) 00106 // Stack-instantiated-non-servants should never have _incr_refcnt called. 00107 // We do not care about stack-instances. Stack-instantiated servants break 00108 // the tracker. 00109 if ( refcount == 1 ) 00110 { 00111 TAO_Notify_Tracker::get_instance().add( this ); 00112 } 00113 #endif 00114 return refcount; 00115 } |
|
|
Definition at line 87 of file Refcountable.h. |