geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbarr...@apache.org
Subject [02/21] geode-native git commit: GEODE-2494: Replace SpinLock with spinlock_mutex.
Date Wed, 01 Mar 2017 23:35:07 GMT
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/7f838e4f
Tree: http://git-wip-us.apache.org/repos/asf/geode-native/tree/7f838e4f
Diff: http://git-wip-us.apache.org/repos/asf/geode-native/diff/7f838e4f

Branch: refs/heads/develop
Commit: 7f838e4f4dccae03e1b71b2f2e85ef8ba9b36134
Parents: f24bb25
Author: Jacob Barrett <jbarrett@pivotal.io>
Authored: Tue Feb 21 22:14:50 2017 -0800
Committer: Jacob Barrett <jbarrett@pivotal.io>
Committed: Wed Mar 1 15:10:42 2017 -0800

----------------------------------------------------------------------
 src/cppcache/src/SerializationRegistry.cpp | 51 +++++++++++++------------
 src/cppcache/src/SerializationRegistry.hpp |  2 +-
 2 files changed, 28 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode-native/blob/7f838e4f/src/cppcache/src/SerializationRegistry.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/SerializationRegistry.cpp b/src/cppcache/src/SerializationRegistry.cpp
index e7f7c27..d0c5917 100644
--- a/src/cppcache/src/SerializationRegistry.cpp
+++ b/src/cppcache/src/SerializationRegistry.cpp
@@ -33,7 +33,6 @@
 #include "EventId.hpp"
 #include <geode/Properties.hpp>
 #include <geode/ExceptionTypes.hpp>
-#include "SpinLock.hpp"
 #include <geode/RegionAttributes.hpp>
 #include "CacheableObjectPartList.hpp"
 #include "ClientConnectionResponse.hpp"
@@ -59,6 +58,9 @@
 
 #include "NonCopyable.hpp"
 
+#include <mutex>
+#include "util/concurrent/spinlock_mutex.hpp"
+
 namespace apache {
 namespace geode {
 namespace client {
@@ -81,9 +83,9 @@ class TheTypeMap : private NonCopyable, private NonAssignable {
   IdToFactoryMap* m_map;
   IdToFactoryMap* m_map2;  // to hold Fixed IDs since GFE 5.7.
   StrToPdxFactoryMap* m_pdxTypemap;
-  SpinLock m_mapLock;
-  SpinLock m_map2Lock;
-  SpinLock m_pdxTypemapLock;
+  spinlock_mutex m_mapLock;
+  spinlock_mutex m_map2Lock;
+  spinlock_mutex m_pdxTypemapLock;
 
  public:
   TheTypeMap();
@@ -166,29 +168,29 @@ class TheTypeMap : private NonCopyable, private NonAssignable {
   }
 
   inline void clear() {
-    SpinLockGuard guard(m_mapLock);
+    std::lock_guard<spinlock_mutex> guard(m_mapLock);
     m_map->unbind_all();
 
-    SpinLockGuard guard2(m_map2Lock);
+    std::lock_guard<spinlock_mutex> guard2(m_map2Lock);
     m_map2->unbind_all();
 
-    SpinLockGuard guard3(m_pdxTypemapLock);
+    std::lock_guard<spinlock_mutex> guard3(m_pdxTypemapLock);
     m_pdxTypemap->unbind_all();
   }
 
   inline void find(int64_t id, TypeFactoryMethod& func) {
-    SpinLockGuard guard(m_mapLock);
+    std::lock_guard<spinlock_mutex> guard(m_mapLock);
     m_map->find(id, func);
   }
 
   inline void find2(int64_t id, TypeFactoryMethod& func) {
-    SpinLockGuard guard(m_map2Lock);
+    std::lock_guard<spinlock_mutex> guard(m_map2Lock);
     m_map2->find(id, func);
   }
 
   inline void bind(TypeFactoryMethod func) {
     Serializable* obj = func();
-    SpinLockGuard guard(m_mapLock);
+    std::lock_guard<spinlock_mutex> guard(m_mapLock);
     int64_t compId = static_cast<int64_t>(obj->typeId());
     if (compId == GeodeTypeIdsImpl::CacheableUserData ||
         compId == GeodeTypeIdsImpl::CacheableUserData2 ||
@@ -217,7 +219,7 @@ class TheTypeMap : private NonCopyable, private NonAssignable {
   }
 
   inline void rebind(int64_t compId, TypeFactoryMethod func) {
-    SpinLockGuard guard(m_mapLock);
+    std::lock_guard<spinlock_mutex> guard(m_mapLock);
     int bindRes = m_map->rebind(compId, func);
     if (bindRes == -1) {
       LOGERROR(
@@ -231,13 +233,13 @@ class TheTypeMap : private NonCopyable, private NonAssignable {
   }
 
   inline void unbind(int64_t compId) {
-    SpinLockGuard guard(m_mapLock);
+    std::lock_guard<spinlock_mutex> guard(m_mapLock);
     m_map->unbind(compId);
   }
 
   inline void bind2(TypeFactoryMethod func) {
     Serializable* obj = func();
-    SpinLockGuard guard(m_map2Lock);
+    std::lock_guard<spinlock_mutex> guard(m_map2Lock);
     int8_t dsfid = obj->DSFID();
 
     int64_t compId = 0;
@@ -268,18 +270,18 @@ class TheTypeMap : private NonCopyable, private NonAssignable {
   }
 
   inline void rebind2(int64_t compId, TypeFactoryMethod func) {
-    SpinLockGuard guard(m_map2Lock);
+    std::lock_guard<spinlock_mutex> guard(m_map2Lock);
     m_map2->rebind(compId, func);
   }
 
   inline void unbind2(int64_t compId) {
-    SpinLockGuard guard(m_map2Lock);
+    std::lock_guard<spinlock_mutex> guard(m_map2Lock);
     m_map2->unbind(compId);
   }
 
   inline void bindPdxType(TypeFactoryMethodPdx func) {
     PdxSerializable* obj = func();
-    SpinLockGuard guard(m_pdxTypemapLock);
+    std::lock_guard<spinlock_mutex> guard(m_pdxTypemapLock);
     const char* objFullName = obj->getClassName();
 
     int bindRes = m_pdxTypemap->bind(objFullName, func);
@@ -302,13 +304,14 @@ class TheTypeMap : private NonCopyable, private NonAssignable {
     }
   }
 
-  inline void findPdxType(char* objFullName, TypeFactoryMethodPdx& func) {
-    SpinLockGuard guard(m_pdxTypemapLock);
+  inline void findPdxType(const char* objFullName, TypeFactoryMethodPdx& func) {
+    std::lock_guard<spinlock_mutex> guard(m_pdxTypemapLock);
     m_pdxTypemap->find(objFullName, func);
   }
 
-  inline void rebindPdxType(char* objFullName, TypeFactoryMethodPdx func) {
-    SpinLockGuard guard(m_pdxTypemapLock);
+  inline void rebindPdxType(const char* objFullName,
+                            TypeFactoryMethodPdx func) {
+    std::lock_guard<spinlock_mutex> guard(m_pdxTypemapLock);
     int bindRes = m_pdxTypemap->rebind(objFullName, func);
     if (bindRes == -1) {
       LOGERROR(
@@ -321,8 +324,8 @@ class TheTypeMap : private NonCopyable, private NonAssignable {
     }
   }
 
-  inline void unbindPdxType(char* objFullName) {
-    SpinLockGuard guard(m_pdxTypemapLock);
+  inline void unbindPdxType(const char* objFullName) {
+    std::lock_guard<spinlock_mutex> guard(m_pdxTypemapLock);
     m_pdxTypemap->unbind(objFullName);
   }
 };
@@ -452,13 +455,13 @@ void SerializationRegistry::init() {
   theTypeMap::instance()->setup();
 }
 
-PdxSerializablePtr SerializationRegistry::getPdxType(char* className) {
+PdxSerializablePtr SerializationRegistry::getPdxType(const char* className) {
   TypeFactoryMethodPdx objectType = NULL;
   theTypeMap::instance()->findPdxType(className, objectType);
   PdxSerializablePtr pdxObj;
   if (objectType == NULL) {
     try {
-      pdxObj = new PdxWrapper((const char*)className);
+      pdxObj = new PdxWrapper(className);
     } catch (const Exception&) {
       LOGERROR(
           "Unregistered class %s during PDX deserialization: Did the "

http://git-wip-us.apache.org/repos/asf/geode-native/blob/7f838e4f/src/cppcache/src/SerializationRegistry.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/SerializationRegistry.hpp b/src/cppcache/src/SerializationRegistry.hpp
index 85783f7..14aec66 100644
--- a/src/cppcache/src/SerializationRegistry.hpp
+++ b/src/cppcache/src/SerializationRegistry.hpp
@@ -146,7 +146,7 @@ class CPPCACHE_EXPORT SerializationRegistry {
   static int32_t GetEnumValue(SerializablePtr enumInfo);
   static SerializablePtr GetEnum(int32_t val);
 
-  static PdxSerializablePtr getPdxType(char* className);
+  static PdxSerializablePtr getPdxType(const char* className);
 
  private:
   static PoolPtr getPool();


Mime
View raw message