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()
: m_cancelled(false)
, m_mutex()
, m_condition(&m_mutex)
, m_condition(m_mutex)
{
TRACE(this);
}

@ -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;
};

@ -4,7 +4,7 @@
#include <time.h>
#include <assert.h>
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<Mutex*>(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<Mutex*>(m_mutex)->getPThreadMutex(),
m_mutex.getPThreadMutex(),
&abs_time );
assert( ret == 0);
}

Loading…
Cancel
Save