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:21 UTC
[20/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/bee14556
Tree: http://git-wip-us.apache.org/repos/asf/geode-native/tree/bee14556
Diff: http://git-wip-us.apache.org/repos/asf/geode-native/diff/bee14556
Branch: refs/heads/feature/GEODE-2602
Commit: bee14556112a56fa142cf9dca3cf2c74881797d4
Parents: 12cb7c9
Author: Jacob Barrett <jb...@pivotal.io>
Authored: Tue Feb 21 22:14:50 2017 -0800
Committer: Jacob Barrett <jb...@pivotal.io>
Committed: Wed Mar 15 10:44:23 2017 -0700
----------------------------------------------------------------------
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/bee14556/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/bee14556/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();