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/01 23:35:19 UTC
[14/21] 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/758a5a18
Tree: http://git-wip-us.apache.org/repos/asf/geode-native/tree/758a5a18
Diff: http://git-wip-us.apache.org/repos/asf/geode-native/diff/758a5a18
Branch: refs/heads/develop
Commit: 758a5a18caae3f186379355d1c97df61bca37330
Parents: 8de83a2
Author: Jacob Barrett <jb...@pivotal.io>
Authored: Wed Feb 22 19:04:10 2017 -0800
Committer: Jacob Barrett <jb...@pivotal.io>
Committed: Wed Mar 1 15:10:43 2017 -0800
----------------------------------------------------------------------
src/cppcache/src/CqQueryVsdStats.cpp | 1 -
src/cppcache/src/CqServiceVsdStats.cpp | 1 -
src/cppcache/src/PoolStatistics.cpp | 19 ++++++-----
src/cppcache/src/PoolStatistics.hpp | 29 ++++++++++++++---
src/cppcache/src/RegionStats.cpp | 49 +++++++++++++++++++++++------
src/cppcache/src/RegionStats.hpp | 24 +++++++-------
6 files changed, 88 insertions(+), 35 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/geode-native/blob/758a5a18/src/cppcache/src/CqQueryVsdStats.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/CqQueryVsdStats.cpp b/src/cppcache/src/CqQueryVsdStats.cpp
index 3076e2e..ceb40a6 100644
--- a/src/cppcache/src/CqQueryVsdStats.cpp
+++ b/src/cppcache/src/CqQueryVsdStats.cpp
@@ -20,7 +20,6 @@
#include "CqQueryVsdStats.hpp"
//#include "StatisticsFactory.hpp"
-#include <ace/Thread_Mutex.h>
#include <ace/Singleton.h>
#include <mutex>
http://git-wip-us.apache.org/repos/asf/geode-native/blob/758a5a18/src/cppcache/src/CqServiceVsdStats.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/CqServiceVsdStats.cpp b/src/cppcache/src/CqServiceVsdStats.cpp
index b78c056..08f331b 100644
--- a/src/cppcache/src/CqServiceVsdStats.cpp
+++ b/src/cppcache/src/CqServiceVsdStats.cpp
@@ -20,7 +20,6 @@
#include "CqServiceVsdStats.hpp"
//#include "StatisticsFactory.hpp"
-#include <ace/Thread_Mutex.h>
#include <ace/Singleton.h>
#include <mutex>
http://git-wip-us.apache.org/repos/asf/geode-native/blob/758a5a18/src/cppcache/src/PoolStatistics.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/PoolStatistics.cpp b/src/cppcache/src/PoolStatistics.cpp
index 6c296aa..d33fb91 100644
--- a/src/cppcache/src/PoolStatistics.cpp
+++ b/src/cppcache/src/PoolStatistics.cpp
@@ -20,25 +20,30 @@
#include "PoolStatistics.hpp"
//#include "StatisticsFactory.hpp"
-#include <ace/Thread_Mutex.h>
#include <ace/Singleton.h>
+#include <mutex>
+
+#include "util/concurrent/spinlock_mutex.hpp"
+
////////////////////////////////////////////////////////////////////////////////
namespace apache {
namespace geode {
namespace client {
-using namespace apache::geode::statistics;
+using statistics::StatisticsFactory;
+using statistics::StatisticsManager;
+using util::concurrent::spinlock_mutex;
////////////////////////////////////////////////////////////////////////////////
PoolStatType* PoolStatType::single = NULL;
-SpinLock PoolStatType::m_singletonLock;
-SpinLock PoolStatType::m_statTypeLock;
+spinlock_mutex PoolStatType::m_singletonLock;
+spinlock_mutex PoolStatType::m_statTypeLock;
void PoolStatType::clean() {
- SpinLockGuard guard(m_singletonLock);
+ std::lock_guard<spinlock_mutex> guard(m_singletonLock);
if (single != NULL) {
delete single;
single = NULL;
@@ -46,7 +51,7 @@ void PoolStatType::clean() {
}
StatisticsType* PoolStatType::getStatType() {
- SpinLockGuard guard(m_statTypeLock);
+ std::lock_guard<spinlock_mutex> guard(m_statTypeLock);
StatisticsFactory* factory = StatisticsFactory::getExistingInstance();
GF_D_ASSERT(!!factory);
@@ -179,7 +184,7 @@ StatisticsType* PoolStatType::getStatType() {
}
PoolStatType* PoolStatType::getInstance() {
- SpinLockGuard guard(m_singletonLock);
+ std::lock_guard<spinlock_mutex> guard(m_singletonLock);
if (single == NULL) {
single = new PoolStatType();
}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/758a5a18/src/cppcache/src/PoolStatistics.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/PoolStatistics.hpp b/src/cppcache/src/PoolStatistics.hpp
index e107b44..c882cfc 100644
--- a/src/cppcache/src/PoolStatistics.hpp
+++ b/src/cppcache/src/PoolStatistics.hpp
@@ -1,10 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#pragma once
#ifndef GEODE_POOLSTATISTICS_H_
#define GEODE_POOLSTATISTICS_H_
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
@@ -24,13 +40,16 @@
#include <geode/statistics/Statistics.hpp>
#include <geode/statistics/StatisticsFactory.hpp>
#include <statistics/StatisticsManager.hpp>
-#include "SpinLock.hpp"
+#include "util/concurrent/spinlock_mutex.hpp"
namespace apache {
namespace geode {
namespace client {
-using namespace apache::geode::statistics;
+using statistics::StatisticDescriptor;
+using statistics::StatisticsType;
+using statistics::Statistics;
+using util::concurrent::spinlock_mutex;
class PoolStats {
public:
@@ -165,8 +184,8 @@ class PoolStats {
class PoolStatType {
private:
static PoolStatType* single;
- static SpinLock m_singletonLock;
- static SpinLock m_statTypeLock;
+ static spinlock_mutex m_singletonLock;
+ static spinlock_mutex m_statTypeLock;
public:
static PoolStatType* getInstance();
http://git-wip-us.apache.org/repos/asf/geode-native/blob/758a5a18/src/cppcache/src/RegionStats.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/RegionStats.cpp b/src/cppcache/src/RegionStats.cpp
index 930fe92..285cf76 100644
--- a/src/cppcache/src/RegionStats.cpp
+++ b/src/cppcache/src/RegionStats.cpp
@@ -23,8 +23,12 @@
#include <ace/Thread_Mutex.h>
#include <ace/Singleton.h>
-const char* statsName = (const char*)"RegionStatistics";
-const char* statsDesc = (const char*)"Statistics for this region";
+#include <mutex>
+
+#include "util/concurrent/spinlock_mutex.hpp"
+
+const char* statsName = "RegionStatistics";
+const char* statsDesc = "Statistics for this region";
////////////////////////////////////////////////////////////////////////////////
@@ -32,16 +36,17 @@ namespace apache {
namespace geode {
namespace client {
-using namespace apache::geode::statistics;
+using statistics::StatisticsFactory;
+using util::concurrent::spinlock_mutex;
////////////////////////////////////////////////////////////////////////////////
RegionStatType* RegionStatType::single = NULL;
-SpinLock RegionStatType::m_singletonLock;
-SpinLock RegionStatType::m_statTypeLock;
+spinlock_mutex RegionStatType::m_singletonLock;
+spinlock_mutex RegionStatType::m_statTypeLock;
void RegionStatType::clean() {
- SpinLockGuard guard(m_singletonLock);
+ std::lock_guard<spinlock_mutex> guard(m_singletonLock);
if (single != NULL) {
delete single;
single = NULL;
@@ -50,7 +55,7 @@ void RegionStatType::clean() {
StatisticsType* RegionStatType::getStatType() {
const bool largerIsBetter = true;
- SpinLockGuard guard(m_statTypeLock);
+ std::lock_guard<spinlock_mutex> guard(m_statTypeLock);
StatisticsFactory* factory = StatisticsFactory::getExistingInstance();
GF_D_ASSERT(!!factory);
@@ -191,14 +196,40 @@ StatisticsType* RegionStatType::getStatType() {
}
RegionStatType* RegionStatType::getInstance() {
- SpinLockGuard guard(m_singletonLock);
+ std::lock_guard<spinlock_mutex> guard(m_singletonLock);
if (single == NULL) {
single = new RegionStatType();
}
return single;
}
-RegionStatType::RegionStatType() {}
+RegionStatType::RegionStatType()
+ : m_destroysId(0),
+ m_createsId(0),
+ m_putsId(0),
+ m_putTimeId(0),
+ m_putAllId(0),
+ m_putAllTimeId(0),
+ m_removeAllId(0),
+ m_removeAllTimeId(0),
+ m_getsId(0),
+ m_getTimeId(0),
+ m_getAllId(0),
+ m_getAllTimeId(0),
+ m_hitsId(0),
+ m_missesId(0),
+ m_entriesId(0),
+ m_overflowsId(0),
+ m_retrievesId(0),
+ m_nonSingleHopId(0),
+ m_metaDataRefreshId(0),
+ m_LoaderCallsCompletedId(0),
+ m_LoaderCallTimeId(0),
+ m_WriterCallsCompletedId(0),
+ m_WriterCallTimeId(0),
+ m_ListenerCallsCompletedId(0),
+ m_ListenerCallTimeId(0),
+ m_clearsId(0) {}
////////////////////////////////////////////////////////////////////////////////
http://git-wip-us.apache.org/repos/asf/geode-native/blob/758a5a18/src/cppcache/src/RegionStats.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/RegionStats.hpp b/src/cppcache/src/RegionStats.hpp
index c077b5f..1f72d77 100644
--- a/src/cppcache/src/RegionStats.hpp
+++ b/src/cppcache/src/RegionStats.hpp
@@ -1,8 +1,3 @@
-#pragma once
-
-#ifndef GEODE_REGIONSTATS_H_
-#define GEODE_REGIONSTATS_H_
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -20,19 +15,24 @@
* limitations under the License.
*/
+#pragma once
+
+#ifndef GEODE_REGIONSTATS_H_
+#define GEODE_REGIONSTATS_H_
+
#include <geode/geode_globals.hpp>
#include <geode/statistics/Statistics.hpp>
#include <geode/statistics/StatisticsFactory.hpp>
-#include "SpinLock.hpp"
-//#include "NanoTimer.hpp"
-//#include <SystemProperties.hpp>
-//#include <../DistributedSystem.hpp>
+#include "util/concurrent/spinlock_mutex.hpp"
namespace apache {
namespace geode {
namespace client {
-using namespace apache::geode::statistics;
+using statistics::StatisticDescriptor;
+using statistics::StatisticsType;
+using statistics::Statistics;
+using util::concurrent::spinlock_mutex;
class CPPCACHE_EXPORT RegionStats {
public:
@@ -130,8 +130,8 @@ class CPPCACHE_EXPORT RegionStats {
class RegionStatType {
private:
static RegionStatType* single;
- static SpinLock m_singletonLock;
- static SpinLock m_statTypeLock;
+ static spinlock_mutex m_singletonLock;
+ static spinlock_mutex m_statTypeLock;
public:
static RegionStatType* getInstance();