diff options
author | Johnny Willemsen <jwillemsen@remedy.nl> | 2005-07-18 09:40:29 +0000 |
---|---|---|
committer | Johnny Willemsen <jwillemsen@remedy.nl> | 2005-07-18 09:40:29 +0000 |
commit | cf8a4f4ae2075dbfa652297c62bc1b94095b9a92 (patch) | |
tree | e56b79246b2ff9b36ef8cb1a9dd355c952a7690e | |
parent | 259e84bedc81e8441167d7fd05347f53f8eabc99 (diff) | |
download | ATCD-cf8a4f4ae2075dbfa652297c62bc1b94095b9a92.tar.gz |
ChangeLogTag: Mon Jul 18 08:43:12 UTC 2005 Johnny Willemsen <jwillemsen@remedy.nl>
-rw-r--r-- | TAO/tao/Any_Impl.cpp | 19 | ||||
-rw-r--r-- | TAO/tao/Any_Impl.h | 10 | ||||
-rw-r--r-- | TAO/tao/LocalObject.cpp | 12 | ||||
-rw-r--r-- | TAO/tao/LocalObject.h | 10 | ||||
-rw-r--r-- | TAO/tao/LocalObject.i | 3 | ||||
-rw-r--r-- | TAO/tao/Messaging/AMH_Response_Handler.cpp | 17 | ||||
-rw-r--r-- | TAO/tao/Valuetype/ValueFactory.cpp | 20 | ||||
-rw-r--r-- | TAO/tao/Valuetype/ValueFactory.h | 5 |
8 files changed, 25 insertions, 71 deletions
diff --git a/TAO/tao/Any_Impl.cpp b/TAO/tao/Any_Impl.cpp index 90315638c32..31930ae2ed9 100644 --- a/TAO/tao/Any_Impl.cpp +++ b/TAO/tao/Any_Impl.cpp @@ -21,7 +21,6 @@ TAO::Any_Impl::Any_Impl (_tao_destructor destructor, : value_destructor_ (destructor) , type_ (CORBA::TypeCode::_duplicate (tc)) , encoded_ (encoded) - , mutex_ () , refcount_ (1) { } @@ -97,28 +96,18 @@ TAO::Any_Impl::_tao_any_wstring_destructor (void *x) void TAO::Any_Impl::_add_ref (void) { - ACE_GUARD (ACE_SYNCH_MUTEX, - guard, - this->mutex_); - ++this->refcount_; } void TAO::Any_Impl::_remove_ref (void) { - { - ACE_GUARD (ACE_SYNCH_MUTEX, - guard, - this->mutex_); + const CORBA::ULong new_count = --this->refcount_; - if (--this->refcount_ != 0) - { - return; - } + if (new_count != 0) + return - this->free_value (); - } + this->free_value (); delete this; } diff --git a/TAO/tao/Any_Impl.h b/TAO/tao/Any_Impl.h index 4802a25e6aa..f3365631728 100644 --- a/TAO/tao/Any_Impl.h +++ b/TAO/tao/Any_Impl.h @@ -25,6 +25,7 @@ #include "ace/Synch_Traits.h" #include "ace/Null_Mutex.h" #include "ace/Thread_Mutex.h" +#include "ace/Atomic_Op.h" class TAO_OutputCDR; class TAO_InputCDR; @@ -92,7 +93,7 @@ namespace TAO virtual CORBA::Boolean to_object (CORBA::Object_ptr &) const; virtual CORBA::Boolean to_value (CORBA::ValueBase *&) const; virtual CORBA::Boolean to_abstract_base (CORBA::AbstractBase_ptr &) const; - + bool encoded (void) const; protected: @@ -106,11 +107,8 @@ namespace TAO bool encoded_; private: - /// Lock for the refcount - ACE_SYNCH_MUTEX mutex_; - - /// Number of outstanding references to this object. - CORBA::ULong refcount_; + /// Reference counter. + ACE_Atomic_Op<TAO_SYNCH_MUTEX, CORBA::ULong> refcount_; }; } diff --git a/TAO/tao/LocalObject.cpp b/TAO/tao/LocalObject.cpp index 9185a471c69..2295556f9ed 100644 --- a/TAO/tao/LocalObject.cpp +++ b/TAO/tao/LocalObject.cpp @@ -215,21 +215,15 @@ CORBA::LocalObject::_get_orb (ACE_ENV_SINGLE_ARG_DECL) void TAO_Local_RefCounted_Object::_add_ref (void) { - ACE_GUARD (TAO_SYNCH_MUTEX, guard, this->refcount_lock_); ++this->refcount_; } void TAO_Local_RefCounted_Object::_remove_ref (void) { - { - ACE_GUARD (TAO_SYNCH_MUTEX, mon, this->refcount_lock_); - --this->refcount_; + const CORBA::ULong new_count = --this->refcount_; - if (this->refcount_ != 0) - return; - } - - delete this; + if (new_count == 0) + delete this; } diff --git a/TAO/tao/LocalObject.h b/TAO/tao/LocalObject.h index c6d682b1ccd..7e7c8e59349 100644 --- a/TAO/tao/LocalObject.h +++ b/TAO/tao/LocalObject.h @@ -21,7 +21,9 @@ #define TAO_CORBA_LOCALOBJECT_H #include /**/ "ace/pre.h" + #include "ace/Thread_Mutex.h" +#include "ace/Atomic_Op.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once @@ -243,12 +245,8 @@ private: //@} protected: - - /// Mutex to protect reference count. - TAO_SYNCH_MUTEX refcount_lock_; - - /// Number of outstanding references to this object. - CORBA::ULong refcount_; + /// Reference counter. + ACE_Atomic_Op<TAO_SYNCH_MUTEX, CORBA::ULong> refcount_; }; diff --git a/TAO/tao/LocalObject.i b/TAO/tao/LocalObject.i index b6d5816c85d..84891887973 100644 --- a/TAO/tao/LocalObject.i +++ b/TAO/tao/LocalObject.i @@ -46,7 +46,6 @@ CORBA::LocalObject::LocalObject (void) ACE_INLINE TAO_Local_RefCounted_Object::TAO_Local_RefCounted_Object (void) - : refcount_lock_ (), - refcount_ (1) + : refcount_ (1) { } diff --git a/TAO/tao/Messaging/AMH_Response_Handler.cpp b/TAO/tao/Messaging/AMH_Response_Handler.cpp index c80275366f3..17239c5b00b 100644 --- a/TAO/tao/Messaging/AMH_Response_Handler.cpp +++ b/TAO/tao/Messaging/AMH_Response_Handler.cpp @@ -232,16 +232,10 @@ TAO_AMH_Response_Handler::_tao_rh_send_exception (CORBA::Exception &ex void TAO_AMH_Response_Handler::_remove_ref (void) { - { - ACE_GUARD (TAO_SYNCH_MUTEX, - mon, - this->refcount_lock_); - - --this->refcount_; + const CORBA::ULong new_count = --this->refcount_; - if (this->refcount_ > 0) - return; - } + if (new_count > 0) + return; if (this->allocator_) { @@ -268,8 +262,3 @@ namespace TAO } } -#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) - -#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) - -#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/tao/Valuetype/ValueFactory.cpp b/TAO/tao/Valuetype/ValueFactory.cpp index 95b9b2c4912..37a8bf6cb79 100644 --- a/TAO/tao/Valuetype/ValueFactory.cpp +++ b/TAO/tao/Valuetype/ValueFactory.cpp @@ -39,30 +39,16 @@ CORBA::ValueFactoryBase::~ValueFactoryBase (void) void CORBA::ValueFactoryBase::_add_ref (void) { - ACE_GUARD (TAO_SYNCH_MUTEX, - guard, - this->_tao_reference_count_lock_); - ++this->_tao_reference_count_; } void CORBA::ValueFactoryBase::_remove_ref (void) { - { - ACE_GUARD (TAO_SYNCH_MUTEX, - guard, - this->_tao_reference_count_lock_); - - --this->_tao_reference_count_; - - if (this->_tao_reference_count_ != 0) - { - return; - } - } + const CORBA::ULong new_count = --this->_tao_reference_count_; - delete this; + if (new_count == 0) + delete this; } // No-op. This should never be called, but it can't be pure virtual. diff --git a/TAO/tao/Valuetype/ValueFactory.h b/TAO/tao/Valuetype/ValueFactory.h index 9d1274e8e57..678a86be8ac 100644 --- a/TAO/tao/Valuetype/ValueFactory.h +++ b/TAO/tao/Valuetype/ValueFactory.h @@ -29,6 +29,7 @@ #include "ace/Thread_Mutex.h" #include "ace/Null_Mutex.h" #include "ace/CORBA_macros.h" +#include "ace/Atomic_Op.h" #include "tao/Environment.h" namespace CORBA @@ -70,8 +71,8 @@ namespace CORBA virtual CORBA::AbstractBase_ptr create_for_unmarshal_abstract (void); private: - CORBA::ULong _tao_reference_count_; - TAO_SYNCH_MUTEX _tao_reference_count_lock_; + /// Reference counter. + ACE_Atomic_Op<TAO_SYNCH_MUTEX, CORBA::ULong> _tao_reference_count_; }; } // End CORBA namespace |