You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ch...@apache.org on 2018/04/10 21:15:11 UTC
qpid-cpp git commit: QPID-7926: [c++ broker] Windows build error
"cannot convert from 'int' to 'qpid::sys::PODMutex'"
Repository: qpid-cpp
Updated Branches:
refs/heads/master 4e8b1de32 -> 9f823d4df
QPID-7926: [c++ broker] Windows build error "cannot convert from 'int' to 'qpid::sys::PODMutex'"
Renamed PODMutex as GlobalMutex. The important point is that it can be used as a
global variable. In POSIX we use a POD class and static initializer to acomplish
this, but on windows we use boost::recursive_mutex, which is documented as being
safe for use as a global variable.
Modified the QPID_MUTEX_INITIALIZER macro to be empty on windows and '= { 0 }'
on POSIX.
This closes #11
Project: http://git-wip-us.apache.org/repos/asf/qpid-cpp/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-cpp/commit/9f823d4d
Tree: http://git-wip-us.apache.org/repos/asf/qpid-cpp/tree/9f823d4d
Diff: http://git-wip-us.apache.org/repos/asf/qpid-cpp/diff/9f823d4d
Branch: refs/heads/master
Commit: 9f823d4df8346e9bf91faeaeeba7896a3a5d332b
Parents: 4e8b1de
Author: Justin Ross <jr...@apache.org>
Authored: Wed Mar 28 06:40:03 2018 -0700
Committer: Alan Conway <ac...@redhat.com>
Committed: Tue Apr 10 09:42:28 2018 -0400
----------------------------------------------------------------------
src/qpid/log/Logger.cpp | 4 ++--
src/qpid/sys/posix/Mutex.h | 18 +++++++++---------
src/qpid/sys/windows/Mutex.h | 35 +++++++++--------------------------
3 files changed, 20 insertions(+), 37 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-cpp/blob/9f823d4d/src/qpid/log/Logger.cpp
----------------------------------------------------------------------
diff --git a/src/qpid/log/Logger.cpp b/src/qpid/log/Logger.cpp
index c480eeb..0ba488e 100644
--- a/src/qpid/log/Logger.cpp
+++ b/src/qpid/log/Logger.cpp
@@ -45,12 +45,12 @@ inline void Logger::enable_unlocked(Statement* s) {
}
namespace {
-sys::PODMutex loggerLock = QPID_MUTEX_INITIALIZER;
+sys::GlobalMutex loggerLock QPID_MUTEX_INITIALIZER;
std::auto_ptr<Logger> logger;
}
Logger& Logger::instance() {
- sys::PODMutex::ScopedLock l(loggerLock);
+ sys::GlobalMutex::ScopedLock l(loggerLock);
if (!logger.get()) logger.reset(new Logger);
return *logger;
}
http://git-wip-us.apache.org/repos/asf/qpid-cpp/blob/9f823d4d/src/qpid/sys/posix/Mutex.h
----------------------------------------------------------------------
diff --git a/src/qpid/sys/posix/Mutex.h b/src/qpid/sys/posix/Mutex.h
index 5d3cfb2..ba63c5a 100644
--- a/src/qpid/sys/posix/Mutex.h
+++ b/src/qpid/sys/posix/Mutex.h
@@ -75,32 +75,32 @@ protected:
/**
- * PODMutex is a POD, can be static-initialized with
- * PODMutex m = QPID_MUTEX_INITIALIZER
+ * GlobalMutex is a POD and must be static-initialized as follows so:
+ * GlobalMutex m QPID_MUTEX_INITIALIZER;
*/
-struct PODMutex
+struct GlobalMutex
{
- typedef ::qpid::sys::ScopedLock<PODMutex> ScopedLock;
+ typedef ::qpid::sys::ScopedLock<GlobalMutex> ScopedLock;
inline void lock();
inline void unlock();
inline bool trylock();
- // Must be public to be a POD:
+ // Must be public to be a Global:
pthread_mutex_t mutex;
};
-#define QPID_MUTEX_INITIALIZER { PTHREAD_MUTEX_INITIALIZER }
+#define QPID_MUTEX_INITIALIZER = { PTHREAD_MUTEX_INITIALIZER }
-void PODMutex::lock() {
+void GlobalMutex::lock() {
QPID_POSIX_ASSERT_THROW_IF(pthread_mutex_lock(&mutex));
}
-void PODMutex::unlock() {
+void GlobalMutex::unlock() {
QPID_POSIX_ASSERT_THROW_IF(pthread_mutex_unlock(&mutex));
}
-bool PODMutex::trylock() {
+bool GlobalMutex::trylock() {
return pthread_mutex_trylock(&mutex) == 0;
}
http://git-wip-us.apache.org/repos/asf/qpid-cpp/blob/9f823d4d/src/qpid/sys/windows/Mutex.h
----------------------------------------------------------------------
diff --git a/src/qpid/sys/windows/Mutex.h b/src/qpid/sys/windows/Mutex.h
index 1bd88c4..1054417 100755
--- a/src/qpid/sys/windows/Mutex.h
+++ b/src/qpid/sys/windows/Mutex.h
@@ -46,7 +46,7 @@ class Mutex : private boost::noncopyable {
public:
typedef ::qpid::sys::ScopedLock<Mutex> ScopedLock;
typedef ::qpid::sys::ScopedUnlock<Mutex> ScopedUnlock;
-
+
inline Mutex();
inline ~Mutex();
inline void lock();
@@ -85,34 +85,17 @@ protected:
/**
- * PODMutex is a POD, can be static-initialized with
- * PODMutex m = QPID_MUTEX_INITIALIZER
+ * GlobalMutex must be declared like this for portabiliity:
+ * GlobalMutex m QPID_MUTEX_INITIALIZER;
+ *
+ * boost::recursive_mutex can be safely used as a global variable so QPID_MUTEX_INITIALIZER
+ * is empty.
*/
-struct PODMutex
-{
- typedef ::qpid::sys::ScopedLock<PODMutex> ScopedLock;
-
- inline void lock();
- inline void unlock();
- inline bool trylock();
-
- // Must be public to be a POD:
- boost::recursive_mutex mutex;
+struct GlobalMutex : public boost::recursive_mutex {
+ typedef ::qpid::sys::ScopedLock<GlobalMutex> ScopedLock;
};
-#define QPID_MUTEX_INITIALIZER 0
-
-void PODMutex::lock() {
- mutex.lock();
-}
-
-void PODMutex::unlock() {
- mutex.unlock();
-}
-
-bool PODMutex::trylock() {
- return mutex.try_lock();
-}
+#define QPID_MUTEX_INITIALIZER
Mutex::Mutex() {
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org