diff options
author | Johnny Willemsen <jwillemsen@remedy.nl> | 2005-07-19 10:12:43 +0000 |
---|---|---|
committer | Johnny Willemsen <jwillemsen@remedy.nl> | 2005-07-19 10:12:43 +0000 |
commit | 58931bcff8836319309cf701d3b26cda6c330577 (patch) | |
tree | 923c49d0d7dea89e16a30ab5522c6e45c9d7c022 /TAO/tao | |
parent | 4a096854f436535c8b01c294965a7c48fbde39f8 (diff) | |
download | ATCD-58931bcff8836319309cf701d3b26cda6c330577.tar.gz |
ChangeLogTag: Tue Jul 19 09:08:12 UTC 2005 Johnny Willemsen <jwillemsen@remedy.nl>
Diffstat (limited to 'TAO/tao')
-rw-r--r-- | TAO/tao/DynamicInterface/Context.cpp | 25 | ||||
-rw-r--r-- | TAO/tao/DynamicInterface/Context.h | 7 | ||||
-rw-r--r-- | TAO/tao/DynamicInterface/Request.h | 2 | ||||
-rw-r--r-- | TAO/tao/DynamicInterface/Server_Request.cpp | 4 | ||||
-rw-r--r-- | TAO/tao/DynamicInterface/Server_Request.h | 2 | ||||
-rw-r--r-- | TAO/tao/Makefile.am | 8 | ||||
-rw-r--r-- | TAO/tao/NVList.cpp | 50 | ||||
-rw-r--r-- | TAO/tao/NVList.h | 16 | ||||
-rw-r--r-- | TAO/tao/Principal.cpp | 12 | ||||
-rw-r--r-- | TAO/tao/Principal.h | 9 | ||||
-rw-r--r-- | TAO/tao/Principal.i | 29 | ||||
-rw-r--r-- | TAO/tao/True_RefCount_Policy.h | 11 | ||||
-rw-r--r-- | TAO/tao/True_RefCount_Policy.inl | 20 | ||||
-rw-r--r-- | TAO/tao/Utils/Synch_Refcountable.cpp (renamed from TAO/tao/Synch_Refcountable.cpp) | 2 | ||||
-rw-r--r-- | TAO/tao/Utils/Synch_Refcountable.h (renamed from TAO/tao/Synch_Refcountable.h) | 5 | ||||
-rw-r--r-- | TAO/tao/Utils/Synch_Refcountable.inl (renamed from TAO/tao/Synch_Refcountable.inl) | 0 | ||||
-rw-r--r-- | TAO/tao/tao.mpc | 2 |
17 files changed, 65 insertions, 139 deletions
diff --git a/TAO/tao/DynamicInterface/Context.cpp b/TAO/tao/DynamicInterface/Context.cpp index 5ffc2fbb355..96b5c1be43b 100644 --- a/TAO/tao/DynamicInterface/Context.cpp +++ b/TAO/tao/DynamicInterface/Context.cpp @@ -28,33 +28,18 @@ CORBA::Context::~Context (void) CORBA::ULong CORBA::Context::_incr_refcnt (void) { - ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, - ace_mon, - this->refcount_lock_, - 0); - - return refcount_++; + return ++refcount_; } CORBA::ULong CORBA::Context::_decr_refcnt (void) { - { - ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, - ace_mon, - this->refcount_lock_, - 0); - - this->refcount_--; + const CORBA::ULong new_count = --this->refcount_; - if (this->refcount_ != 0) - { - return this->refcount_; - } - } + if (new_count == 0) + delete this; - delete this; - return 0; + return new_count; } const char * diff --git a/TAO/tao/DynamicInterface/Context.h b/TAO/tao/DynamicInterface/Context.h index 82b9a5b0a0a..ca807b95828 100644 --- a/TAO/tao/DynamicInterface/Context.h +++ b/TAO/tao/DynamicInterface/Context.h @@ -117,11 +117,8 @@ namespace CORBA typedef CORBA::Context_var _var_type; private: - /// Reference counting. - CORBA::ULong refcount_; - - /// Protect the reference count. - TAO_SYNCH_MUTEX refcount_lock_; + /// Reference counter. + ACE_Atomic_Op<TAO_SYNCH_MUTEX, CORBA::ULong> refcount_; }; /** diff --git a/TAO/tao/DynamicInterface/Request.h b/TAO/tao/DynamicInterface/Request.h index b0d112980da..3dad44d123a 100644 --- a/TAO/tao/DynamicInterface/Request.h +++ b/TAO/tao/DynamicInterface/Request.h @@ -247,7 +247,7 @@ namespace CORBA /// Reference counting. CORBA::ULong refcount_; - /// Protect the refcount_ and response_receieved_. + /// Protect the refcount_ and response_received_. TAO_SYNCH_MUTEX lock_; /// If not zero then the NVList is not evaluated by default. diff --git a/TAO/tao/DynamicInterface/Server_Request.cpp b/TAO/tao/DynamicInterface/Server_Request.cpp index 24ad4096f03..6bd85a21e5e 100644 --- a/TAO/tao/DynamicInterface/Server_Request.cpp +++ b/TAO/tao/DynamicInterface/Server_Request.cpp @@ -29,7 +29,7 @@ CORBA::ServerRequest::_incr_refcnt (void) this->lock_, 0); - return this->refcount_++; + return ++this->refcount_; } CORBA::ULong @@ -41,7 +41,7 @@ CORBA::ServerRequest::_decr_refcnt (void) this->lock_, 0); - this->refcount_--; + --this->refcount_; if (this->refcount_ != 0) { diff --git a/TAO/tao/DynamicInterface/Server_Request.h b/TAO/tao/DynamicInterface/Server_Request.h index 94866615b88..2db2bed43c8 100644 --- a/TAO/tao/DynamicInterface/Server_Request.h +++ b/TAO/tao/DynamicInterface/Server_Request.h @@ -161,7 +161,7 @@ namespace CORBA /// Reference counting. CORBA::ULong refcount_; - /// Protect the refcount_ and response_receieved_. + /// Protect the refcount_ and response_received_. TAO_SYNCH_MUTEX lock_; /// Request from the ORB. diff --git a/TAO/tao/Makefile.am b/TAO/tao/Makefile.am index aec197a33b8..7b936aacdbd 100644 --- a/TAO/tao/Makefile.am +++ b/TAO/tao/Makefile.am @@ -259,7 +259,6 @@ libTAO_la_SOURCES = \ Sync_Strategies.cpp \ Synch_Invocation.cpp \ Synch_Queued_Message.cpp \ - Synch_Refcountable.cpp \ Synch_Reply_Dispatcher.cpp \ SystemException.cpp \ SystemExceptionA.cpp \ @@ -772,8 +771,6 @@ nobase_include_HEADERS = \ Synch_Invocation.h \ Synch_Invocation.inl \ Synch_Queued_Message.h \ - Synch_Refcountable.h \ - Synch_Refcountable.inl \ Synch_Reply_Dispatcher.h \ SystemException.h \ SystemException.inl \ @@ -2859,7 +2856,8 @@ libTAO_Utils_la_SOURCES = \ Utils/PolicyList_Destroyer.cpp \ Utils/RIR_Narrow.cpp \ Utils/Servant_Var.cpp \ - Utils/Server_Main.cpp + Utils/Server_Main.cpp \ + Utils/Synch_Refcountable.cpp libTAO_Utils_la_LDFLAGS = \ -version-number @TAO_MAJOR@:@TAO_MINOR@:@TAO_BETA@ @@ -2883,6 +2881,8 @@ nobase_include_HEADERS += \ Utils/Servant_Var.h \ Utils/Servant_Var.inl \ Utils/Server_Main.h \ + Utils/Synch_Refcountable.h \ + Utils/Synch_Refcountable.inl \ Utils/utils_export.h pkgconfig_DATA += \ diff --git a/TAO/tao/NVList.cpp b/TAO/tao/NVList.cpp index 39a8f7f69b9..547d1942f64 100644 --- a/TAO/tao/NVList.cpp +++ b/TAO/tao/NVList.cpp @@ -30,25 +30,18 @@ ACE_RCSID (tao, CORBA::ULong CORBA::NamedValue::_incr_refcnt (void) { - ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, ace_mon, this->refcount_lock_, 0); - return this->refcount_++; + return ++this->refcount_; } CORBA::ULong CORBA::NamedValue::_decr_refcnt (void) { - { - ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, ace_mon, this->refcount_lock_, 0); - this->refcount_--; - - if (this->refcount_ != 0) - { - return this->refcount_; - } - } - - delete this; - return 0; + const CORBA::ULong new_count = --this->refcount_; + + if (new_count == 0) + delete this; + + return new_count; } CORBA::NamedValue::~NamedValue (void) @@ -66,25 +59,18 @@ CORBA::NamedValue::~NamedValue (void) CORBA::ULong CORBA::NVList::_incr_refcnt (void) { - ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, ace_mon, this->refcount_lock_, 0); - return this->refcount_++; + return ++this->refcount_; } CORBA::ULong CORBA::NVList::_decr_refcnt (void) { - { - ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, ace_mon, this->refcount_lock_, 0); - this->refcount_--; - - if (this->refcount_ != 0) - { - return this->refcount_; - } - } - - delete this; - return 0; + const CORBA::ULong new_count = --this->refcount_; + + if (new_count == 0) + delete this; + + return new_count; } CORBA::NVList::~NVList (void) @@ -314,7 +300,7 @@ CORBA::NVList::_tao_incoming_cdr (TAO_InputCDR &cdr, return; } - ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->refcount_lock_); + ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->lock_); if (this->incoming_ != 0) { @@ -333,7 +319,7 @@ CORBA::NVList::_tao_encode (TAO_OutputCDR &cdr, { ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, - this->refcount_lock_); + this->lock_); if (this->incoming_ != 0) { @@ -460,7 +446,7 @@ CORBA::NVList::_tao_target_alignment (void) { ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, ace_mon, - this->refcount_lock_, + this->lock_, ACE_CDR::MAX_ALIGNMENT); if (this->incoming_ == 0) @@ -482,7 +468,7 @@ CORBA::NVList::_tao_target_alignment (void) void CORBA::NVList::evaluate (ACE_ENV_SINGLE_ARG_DECL) { - ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->refcount_lock_); + ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->lock_); if (this->incoming_ == 0) { diff --git a/TAO/tao/NVList.h b/TAO/tao/NVList.h index a4b0db3f1cc..6252b5f179a 100644 --- a/TAO/tao/NVList.h +++ b/TAO/tao/NVList.h @@ -24,6 +24,7 @@ #include "ace/Unbounded_Queue.h" #include "ace/Thread_Mutex.h" +#include "ace/Atomic_Op.h" #include "tao/CORBA_methods.h" #include "tao/Any.h" @@ -119,11 +120,8 @@ namespace CORBA private: - /// maintains how many references exist to this object - ULong refcount_; - - /// Protects the reference count. - TAO_SYNCH_MUTEX refcount_lock_; + /// Reference counter. + ACE_Atomic_Op<TAO_SYNCH_MUTEX, ULong> refcount_; /// holds the value Any any_; @@ -285,11 +283,11 @@ namespace CORBA /// maximum length of list ULong max_; - /// maintains how many references exist to this object - ULong refcount_; + /// Reference counter. + ACE_Atomic_Op<TAO_SYNCH_MUTEX, ULong> refcount_; - /// Protects the reference count. - TAO_SYNCH_MUTEX refcount_lock_; + /// Protects the incoming pointer. + TAO_SYNCH_MUTEX lock_; /** * When the NVList is used as part of a Server Request we can simply diff --git a/TAO/tao/Principal.cpp b/TAO/tao/Principal.cpp index 9115a79f5f4..048c289c0e5 100644 --- a/TAO/tao/Principal.cpp +++ b/TAO/tao/Principal.cpp @@ -61,15 +61,3 @@ operator>> (TAO_InputCDR & cdr, CORBA::Principal *& x) return (CORBA::Boolean) cdr.good_bit (); } -#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) - - template class TAO_Pseudo_Var_T<CORBA::Principal>; - template class TAO_Pseudo_Out_T<CORBA::Principal, CORBA::Principal_var>; - -#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) - -# pragma instantiate TAO_Pseudo_Var_T<CORBA::Principal> -# pragma instantiate TAO_Pseudo_Out_T<CORBA::Principal, CORBA::Principal_var> - -#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ - diff --git a/TAO/tao/Principal.h b/TAO/tao/Principal.h index c64bf36b3e9..4010df0a507 100644 --- a/TAO/tao/Principal.h +++ b/TAO/tao/Principal.h @@ -24,6 +24,7 @@ # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ +#include "ace/Atomic_Op.h" #include "OctetSeqC.h" #include "Pseudo_VarOut_T.h" #include "CORBA_methods.h" @@ -88,12 +89,8 @@ namespace CORBA Principal (const CORBA::Principal_ptr &); private: - /// Number of outstanding references to this object. - CORBA::ULong refcount_; - - /// Protect the reference count, this is OK because we do no - /// duplicates or releases on the critical path. - TAO_SYNCH_MUTEX refcount_mutex_; + /// Reference counter. + ACE_Atomic_Op<TAO_SYNCH_MUTEX, CORBA::ULong> refcount_; }; } // End CORBA namespace diff --git a/TAO/tao/Principal.i b/TAO/tao/Principal.i index 5b9f0a8865d..559ddb82db0 100644 --- a/TAO/tao/Principal.i +++ b/TAO/tao/Principal.i @@ -2,31 +2,26 @@ // // $Id$ -ACE_INLINE +ACE_INLINE CORBA::Boolean CORBA::is_nil (CORBA::Principal_ptr principal) { - return (CORBA::Boolean) (principal == 0); + return principal == 0; } -ACE_INLINE +ACE_INLINE CORBA::ULong CORBA::Principal::_decr_refcnt (void) { - { - this->refcount_--; + const CORBA::ULong new_count = --this->refcount_; - if (this->refcount_ != 0) - { - return this->refcount_; - } - } + if (new_count == 0) + delete this; - delete this; - return 0; + return new_count; } -ACE_INLINE +ACE_INLINE void CORBA::release (CORBA::Principal_ptr principal) { @@ -36,15 +31,15 @@ CORBA::release (CORBA::Principal_ptr principal) } } -ACE_INLINE +ACE_INLINE CORBA::ULong CORBA::Principal::_incr_refcnt (void) { - return this->refcount_++; + return ++this->refcount_; } -ACE_INLINE +ACE_INLINE CORBA::Principal * CORBA::Principal::_duplicate (CORBA::Principal * x) { @@ -57,7 +52,7 @@ CORBA::Principal::_duplicate (CORBA::Principal * x) } -ACE_INLINE +ACE_INLINE CORBA::Principal * CORBA::Principal::_nil (void) { diff --git a/TAO/tao/True_RefCount_Policy.h b/TAO/tao/True_RefCount_Policy.h index 64efa5220f5..fb2ce06f2e6 100644 --- a/TAO/tao/True_RefCount_Policy.h +++ b/TAO/tao/True_RefCount_Policy.h @@ -27,7 +27,7 @@ #include "tao/orbconf.h" #include "ace/Thread_Mutex.h" - +#include "ace/Atomic_Op.h" namespace TAO { @@ -100,13 +100,8 @@ namespace TAO virtual ~True_RefCount_Policy (void); private: - - /// Lock used to synchronize reference count. - TAO_SYNCH_MUTEX lock_; - - /// Reference count. - unsigned int refcount_; - + /// Reference counter. + ACE_Atomic_Op<TAO_SYNCH_MUTEX, unsigned long> refcount_; }; } // End namespace TAO diff --git a/TAO/tao/True_RefCount_Policy.inl b/TAO/tao/True_RefCount_Policy.inl index a6db939e129..87b1b1b9159 100644 --- a/TAO/tao/True_RefCount_Policy.inl +++ b/TAO/tao/True_RefCount_Policy.inl @@ -3,35 +3,23 @@ // $Id$ -#include "ace/Guard_T.h" - - ACE_INLINE TAO::True_RefCount_Policy::True_RefCount_Policy (void) - : lock_ (), - refcount_ (1) + : refcount_ (1) { } ACE_INLINE void TAO::True_RefCount_Policy::add_ref (void) { - ACE_GUARD (TAO_SYNCH_MUTEX, monitor, this->lock_); - ++this->refcount_; } ACE_INLINE void TAO::True_RefCount_Policy::remove_ref (void) { - { - ACE_GUARD (TAO_SYNCH_MUTEX, monitor, this->lock_); - - --this->refcount_; - - if (this->refcount_ != 0) - return; - } + const unsigned long new_count = --this->refcount_; - delete this; + if (new_count == 0) + delete this; } diff --git a/TAO/tao/Synch_Refcountable.cpp b/TAO/tao/Utils/Synch_Refcountable.cpp index 206106d7930..2b79deb80e0 100644 --- a/TAO/tao/Synch_Refcountable.cpp +++ b/TAO/tao/Utils/Synch_Refcountable.cpp @@ -6,7 +6,7 @@ #include "ace/Log_Msg.h" -ACE_RCSID (tao, +ACE_RCSID (Utils, Synch_Refcountable, "$Id$") diff --git a/TAO/tao/Synch_Refcountable.h b/TAO/tao/Utils/Synch_Refcountable.h index d66b5bb20fb..0e18e9402eb 100644 --- a/TAO/tao/Synch_Refcountable.h +++ b/TAO/tao/Utils/Synch_Refcountable.h @@ -23,8 +23,7 @@ # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "TAO_Export.h" +#include "utils_export.h" class ACE_Lock; @@ -33,7 +32,7 @@ class ACE_Lock; * * @brief Definition for a synchronised refcountable interface. */ -class TAO_Export TAO_Synch_Refcountable : private ACE_Refcountable +class TAO_UTILS_Export TAO_Synch_Refcountable : private ACE_Refcountable { public: virtual ~TAO_Synch_Refcountable (void); diff --git a/TAO/tao/Synch_Refcountable.inl b/TAO/tao/Utils/Synch_Refcountable.inl index 2f4cc32778d..2f4cc32778d 100644 --- a/TAO/tao/Synch_Refcountable.inl +++ b/TAO/tao/Utils/Synch_Refcountable.inl diff --git a/TAO/tao/tao.mpc b/TAO/tao/tao.mpc index 7b2aa85f21b..bbe3cd2078a 100644 --- a/TAO/tao/tao.mpc +++ b/TAO/tao/tao.mpc @@ -240,7 +240,6 @@ project(TAO) : acelib, core, tao_output, taodefaults, pidl, extra_core { Sync_Strategies.cpp Synch_Invocation.cpp Synch_Queued_Message.cpp - Synch_Refcountable.cpp Synch_Reply_Dispatcher.cpp SystemException.cpp SystemExceptionA.cpp @@ -581,7 +580,6 @@ project(TAO) : acelib, core, tao_output, taodefaults, pidl, extra_core { Stub.h Synch_Invocation.h Synch_Queued_Message.h - Synch_Refcountable.h Synch_Reply_Dispatcher.h Sync_Strategies.h SystemException.h |