THRIFT-4151: disable pthread concurrency analysis code in standard builds
Client: C++
This closes #1229
diff --git a/lib/cpp/README.md b/lib/cpp/README.md
index 2bee2ec..05aef95 100755
--- a/lib/cpp/README.md
+++ b/lib/cpp/README.md
@@ -272,3 +272,10 @@
The PRNG seed is key to the application security. This method should be
overridden if it's not strong enough for you.
+
+# Breaking Changes
+
+## 0.11.0
+
+In the pthread mutex implementation, the contention profiling code was enabled
+by default in all builds. This changed to be disabled by default. (THRIFT-4151)
diff --git a/lib/cpp/src/thrift/concurrency/Mutex.cpp b/lib/cpp/src/thrift/concurrency/Mutex.cpp
index e5e50f7..b6b915d 100644
--- a/lib/cpp/src/thrift/concurrency/Mutex.cpp
+++ b/lib/cpp/src/thrift/concurrency/Mutex.cpp
@@ -35,7 +35,10 @@
namespace thrift {
namespace concurrency {
-#ifndef THRIFT_NO_CONTENTION_PROFILING
+// Enable this to turn on mutex contention profiling support
+// #define THRIFT_PTHREAD_MUTEX_CONTENTION_PROFILING
+
+#ifdef THRIFT_PTHREAD_MUTEX_CONTENTION_PROFILING
static int32_t mutexProfilingCounter = 0;
static int32_t mutexProfilingSampleRate = 0;
@@ -105,7 +108,7 @@
#define PROFILE_MUTEX_LOCKED()
#define PROFILE_MUTEX_START_UNLOCK()
#define PROFILE_MUTEX_UNLOCKED()
-#endif // THRIFT_NO_CONTENTION_PROFILING
+#endif // THRIFT_PTHREAD_MUTEX_CONTENTION_PROFILING
/**
* Implementation of Mutex class using POSIX mutex
@@ -115,7 +118,7 @@
class Mutex::impl {
public:
impl(Initializer init) : initialized_(false) {
-#ifndef THRIFT_NO_CONTENTION_PROFILING
+#ifdef THRIFT_PTHREAD_MUTEX_CONTENTION_PROFILING
profileTime_ = 0;
#endif
init(&pthread_mutex_);
@@ -186,7 +189,7 @@
private:
mutable pthread_mutex_t pthread_mutex_;
mutable bool initialized_;
-#ifndef THRIFT_NO_CONTENTION_PROFILING
+#ifdef THRIFT_PTHREAD_MUTEX_CONTENTION_PROFILING
mutable int64_t profileTime_;
#endif
};
@@ -269,7 +272,7 @@
class ReadWriteMutex::impl {
public:
impl() : initialized_(false) {
-#ifndef THRIFT_NO_CONTENTION_PROFILING
+#ifdef THRIFT_PTHREAD_MUTEX_CONTENTION_PROFILING
profileTime_ = 0;
#endif
int ret = pthread_rwlock_init(&rw_lock_, NULL);
@@ -312,7 +315,7 @@
private:
mutable pthread_rwlock_t rw_lock_;
mutable bool initialized_;
-#ifndef THRIFT_NO_CONTENTION_PROFILING
+#ifdef THRIFT_PTHREAD_MUTEX_CONTENTION_PROFILING
mutable int64_t profileTime_;
#endif
};