summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohnny Willemsen <jwillemsen@remedy.nl>2019-06-10 19:31:04 +0200
committerJohnny Willemsen <jwillemsen@remedy.nl>2019-06-10 19:31:04 +0200
commit2211b831b81dbac580dea499d016132b59805b4f (patch)
tree3ede8279ace0a4a41622ce644bae0bac24b2d121
parent6b84a09f60463bfd831e7f55a03000690847d44c (diff)
downloadATCD-2211b831b81dbac580dea499d016132b59805b4f.tar.gz
Make use of an atomic for the refcount instead of a full mutex
* TAO/orbsvcs/ImplRepo_Service/AsyncListManager.cpp: * TAO/orbsvcs/ImplRepo_Service/AsyncListManager.h:
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/AsyncListManager.cpp19
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/AsyncListManager.h12
2 files changed, 18 insertions, 13 deletions
diff --git a/TAO/orbsvcs/ImplRepo_Service/AsyncListManager.cpp b/TAO/orbsvcs/ImplRepo_Service/AsyncListManager.cpp
index 959e2879ebf..0934f68f194 100644
--- a/TAO/orbsvcs/ImplRepo_Service/AsyncListManager.cpp
+++ b/TAO/orbsvcs/ImplRepo_Service/AsyncListManager.cpp
@@ -21,8 +21,7 @@ AsyncListManager::AsyncListManager (const Locator_Repository *repo,
first_ (0),
how_many_ (0),
waiters_ (0),
- refcount_ (1),
- lock_ ()
+ refcount_ (1)
{
}
@@ -78,7 +77,7 @@ AsyncListManager::init_list (void)
{
if (!evaluate_status (i, l->status(), info->pid))
{
- this->waiters_++;
+ ++this->waiters_;
}
else
{
@@ -316,7 +315,6 @@ AsyncListManager::ping_replied (CORBA::ULong index, LiveStatus status, int pid)
AsyncListManager *
AsyncListManager::_add_ref (void)
{
- ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, mon, this->lock_, 0);
++this->refcount_;
return this;
}
@@ -324,11 +322,8 @@ AsyncListManager::_add_ref (void)
void
AsyncListManager::_remove_ref (void)
{
- int count = 0;
- {
- ACE_GUARD (TAO_SYNCH_MUTEX, mon, this->lock_);
- count = --this->refcount_;
- }
+ int const count = --this->refcount_;
+
if (count == 0)
{
delete this;
@@ -360,7 +355,7 @@ ListLiveListener::~ListLiveListener (void)
bool
ListLiveListener::start (void)
{
- bool rtn = this->pinger_.add_poll_listener (this);
+ bool const rtn = this->pinger_.add_poll_listener (this);
this->started_ = true;
return rtn;
}
@@ -388,7 +383,9 @@ ListLiveListener::status_changed (LiveStatus status)
else
{
if (this->started_)
- this->owner_->ping_replied (this->index_, status, this->pid_);
+ {
+ this->owner_->ping_replied (this->index_, status, this->pid_);
+ }
}
return true;
}
diff --git a/TAO/orbsvcs/ImplRepo_Service/AsyncListManager.h b/TAO/orbsvcs/ImplRepo_Service/AsyncListManager.h
index bd722dd71ca..101a0ceb880 100644
--- a/TAO/orbsvcs/ImplRepo_Service/AsyncListManager.h
+++ b/TAO/orbsvcs/ImplRepo_Service/AsyncListManager.h
@@ -19,6 +19,11 @@
#endif /* ACE_LACKS_PRAGMA_ONCE */
#include "tao/Intrusive_Ref_Count_Handle_T.h"
+#if defined (ACE_HAS_CPP11)
+# include <atomic>
+#else
+# include "ace/Atomic_Op.h"
+#endif /* ACE_HAS_CPP11 */
#include "LiveCheck.h"
class Locator_Repository;
@@ -73,8 +78,11 @@ class AsyncListManager
CORBA::ULong first_;
CORBA::ULong how_many_;
CORBA::ULong waiters_;
- int refcount_;
- TAO_SYNCH_MUTEX lock_;
+#if defined (ACE_HAS_CPP11)
+ std::atomic<int> refcount_;
+#else
+ ACE_Atomic_Op<TAO_SYNCH_MUTEX, int> refcount_;
+#endif /* ACE_HAS_CPP11 */
};
typedef TAO_Intrusive_Ref_Count_Handle<AsyncListManager> AsyncListManager_ptr;