From efd39fd208f185861697d480d4e4128172013b2b Mon Sep 17 00:00:00 2001 From: Denes Matetelki Date: Mon, 28 Feb 2011 15:54:13 +0100 Subject: [PATCH] ConditionalVariable takes Mutex as reference, not as pointer --- include/ConcurrentQueue.hpp | 2 +- include/ConditionVariable.hpp | 4 ++-- src/ConditionVariable.cpp | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/ConcurrentQueue.hpp b/include/ConcurrentQueue.hpp index 075492d..e2f763c 100644 --- a/include/ConcurrentQueue.hpp +++ b/include/ConcurrentQueue.hpp @@ -21,7 +21,7 @@ class ConcurrentQueue { ConcurrentQueue() : m_cancelled(false) , m_mutex() - , m_condition(&m_mutex) + , m_condition(m_mutex) { TRACE(this); } diff --git a/include/ConditionVariable.hpp b/include/ConditionVariable.hpp index 889c546..8afabaa 100644 --- a/include/ConditionVariable.hpp +++ b/include/ConditionVariable.hpp @@ -9,7 +9,7 @@ class ConditionVariable public: - ConditionVariable(const Mutex* const mutex); + ConditionVariable(Mutex& mutex); ~ConditionVariable(); void wait(const int interval = 0); @@ -21,7 +21,7 @@ private: ConditionVariable(const ConditionVariable&); ConditionVariable& operator=(const ConditionVariable&); - const Mutex* const m_mutex; + Mutex& m_mutex; pthread_cond_t m_condVar; }; diff --git a/src/ConditionVariable.cpp b/src/ConditionVariable.cpp index 739cd7e..cc775b8 100644 --- a/src/ConditionVariable.cpp +++ b/src/ConditionVariable.cpp @@ -4,7 +4,7 @@ #include #include -ConditionVariable::ConditionVariable(const Mutex* const mutex) +ConditionVariable::ConditionVariable(Mutex& mutex) : m_mutex(mutex) { TRACE(this); @@ -26,7 +26,7 @@ void ConditionVariable::wait(const int interval) TRACE(this); if ( interval == 0 ) { int ret = pthread_cond_wait( &m_condVar, - const_cast(m_mutex)->getPThreadMutex() ); + m_mutex.getPThreadMutex() ); assert( ret == 0); } else { timespec abs_time; @@ -37,7 +37,7 @@ void ConditionVariable::wait(const int interval) abs_time.tv_sec += 1; } int ret = pthread_cond_timedwait( &m_condVar, - const_cast(m_mutex)->getPThreadMutex(), + m_mutex.getPThreadMutex(), &abs_time ); assert( ret == 0); }