You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by jb...@apache.org on 2017/03/15 17:51:19 UTC

[18/34] geode-native git commit: GEODE-2494: Replace SpinLock with spinlock_mutex.

GEODE-2494: Replace SpinLock with spinlock_mutex.

- Cleanup C++ standards.


Project: http://git-wip-us.apache.org/repos/asf/geode-native/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode-native/commit/12cb7c95
Tree: http://git-wip-us.apache.org/repos/asf/geode-native/tree/12cb7c95
Diff: http://git-wip-us.apache.org/repos/asf/geode-native/diff/12cb7c95

Branch: refs/heads/feature/GEODE-2602
Commit: 12cb7c95c196f475b5868c5d3e556ab404985c0e
Parents: 30c6fc7
Author: Jacob Barrett <jb...@pivotal.io>
Authored: Tue Feb 21 22:00:21 2017 -0800
Committer: Jacob Barrett <jb...@pivotal.io>
Committed: Wed Mar 15 10:44:22 2017 -0700

----------------------------------------------------------------------
 src/cppcache/src/PooledBasePool.hpp | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode-native/blob/12cb7c95/src/cppcache/src/PooledBasePool.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/PooledBasePool.hpp b/src/cppcache/src/PooledBasePool.hpp
index f065cb1..2e5cc23 100644
--- a/src/cppcache/src/PooledBasePool.hpp
+++ b/src/cppcache/src/PooledBasePool.hpp
@@ -22,23 +22,27 @@
 
 #include <geode/geode_globals.hpp>
 #include <geode/SharedPtr.hpp>
-#include "SpinLock.hpp"
 #include "PooledBase.hpp"
 #include <deque>
 
+#include <mutex>
+#include "util/concurrent/spinlock_mutex.hpp"
+
 namespace apache {
 namespace geode {
 namespace client {
 
+using util::concurrent::spinlock_mutex;
+
 class CPPCACHE_EXPORT PooledBasePool {
-  SpinLock m_poolLock;
+  spinlock_mutex m_poolLock;
   std::deque<PooledBase*> m_pooldata;
 
  public:
   PooledBasePool() : m_poolLock(), m_pooldata() {}
 
   ~PooledBasePool() {
-    SpinLockGuard guard(m_poolLock);
+    std::lock_guard<spinlock_mutex> guard(m_poolLock);
     while (!m_pooldata.empty()) {
       PooledBase* item = m_pooldata.front();
       m_pooldata.pop_front();
@@ -49,28 +53,28 @@ class CPPCACHE_EXPORT PooledBasePool {
   inline void returnToPool(PooledBase* poolable) {
     poolable->prePool();
     {
-      SpinLockGuard guard(m_poolLock);
+      std::lock_guard<spinlock_mutex> guard(m_poolLock);
       m_pooldata.push_back(const_cast<PooledBase*>(poolable));
     }
   }
 
   inline PooledBase* takeFromPool() {
-    PooledBase* result = NULL;
+    PooledBase* result = nullptr;
     {
-      SpinLockGuard guard(m_poolLock);
+      std::lock_guard<spinlock_mutex> guard(m_poolLock);
       if (!m_pooldata.empty()) {
         result = m_pooldata.front();
         m_pooldata.pop_front();
       }
     }
-    if (result != NULL) {
+    if (result != nullptr) {
       result->postPool();
     }
     return result;
   }
 
   inline void clear() {
-    SpinLockGuard guard(m_poolLock);
+    std::lock_guard<spinlock_mutex> guard(m_poolLock);
     while (!m_pooldata.empty()) {
       PooledBase* item = m_pooldata.front();
       m_pooldata.pop_front();