ConditionalVariable takes Mutex as reference, not as pointer

master
Denes Matetelki 14 years ago
parent f6493685d1
commit efd39fd208

@ -21,7 +21,7 @@ class ConcurrentQueue {
ConcurrentQueue() ConcurrentQueue()
: m_cancelled(false) : m_cancelled(false)
, m_mutex() , m_mutex()
, m_condition(&m_mutex) , m_condition(m_mutex)
{ {
TRACE(this); TRACE(this);
} }

@ -9,7 +9,7 @@ class ConditionVariable
public: public:
ConditionVariable(const Mutex* const mutex); ConditionVariable(Mutex& mutex);
~ConditionVariable(); ~ConditionVariable();
void wait(const int interval = 0); void wait(const int interval = 0);
@ -21,7 +21,7 @@ private:
ConditionVariable(const ConditionVariable&); ConditionVariable(const ConditionVariable&);
ConditionVariable& operator=(const ConditionVariable&); ConditionVariable& operator=(const ConditionVariable&);
const Mutex* const m_mutex; Mutex& m_mutex;
pthread_cond_t m_condVar; pthread_cond_t m_condVar;
}; };

@ -4,7 +4,7 @@
#include <time.h> #include <time.h>
#include <assert.h> #include <assert.h>
ConditionVariable::ConditionVariable(const Mutex* const mutex) ConditionVariable::ConditionVariable(Mutex& mutex)
: m_mutex(mutex) : m_mutex(mutex)
{ {
TRACE(this); TRACE(this);
@ -26,7 +26,7 @@ void ConditionVariable::wait(const int interval)
TRACE(this); TRACE(this);
if ( interval == 0 ) { if ( interval == 0 ) {
int ret = pthread_cond_wait( &m_condVar, int ret = pthread_cond_wait( &m_condVar,
const_cast<Mutex*>(m_mutex)->getPThreadMutex() ); m_mutex.getPThreadMutex() );
assert( ret == 0); assert( ret == 0);
} else { } else {
timespec abs_time; timespec abs_time;
@ -37,7 +37,7 @@ void ConditionVariable::wait(const int interval)
abs_time.tv_sec += 1; abs_time.tv_sec += 1;
} }
int ret = pthread_cond_timedwait( &m_condVar, int ret = pthread_cond_timedwait( &m_condVar,
const_cast<Mutex*>(m_mutex)->getPThreadMutex(), m_mutex.getPThreadMutex(),
&abs_time ); &abs_time );
assert( ret == 0); assert( ret == 0);
} }

Loading…
Cancel
Save