ScopedLock takes Mutex as reference not as pointer

master
Denes Matetelki 14 years ago
parent f2e7c786c4
commit f6493685d1

@ -35,7 +35,7 @@ class ConcurrentQueue {
void push(const T task)
{
TRACE(this);
ScopedLock sl(&m_mutex);
ScopedLock sl(m_mutex);
if (m_cancelled) throw CancelledException();
m_queue.push( task );
m_condition.signal();
@ -45,7 +45,7 @@ class ConcurrentQueue {
bool tryPop(T &popped_value)
{
TRACE(this);
ScopedLock sl(&m_mutex);
ScopedLock sl(m_mutex);
if (m_cancelled) throw CancelledException();
if ( m_queue.empty() ) return false;
@ -58,7 +58,7 @@ class ConcurrentQueue {
T waitAndPop()
{
TRACE(this);
ScopedLock sl(&m_mutex);
ScopedLock sl(m_mutex);
while ( m_queue.empty() and not m_cancelled) {
m_condition.wait();
@ -74,7 +74,7 @@ class ConcurrentQueue {
bool empty() const
{
TRACE(this);
ScopedLock sl(&m_mutex);
ScopedLock sl(m_mutex);
if (m_cancelled) throw CancelledException();
return m_queue.empty();
}
@ -83,7 +83,7 @@ class ConcurrentQueue {
void cancel()
{
TRACE(this);
ScopedLock sl(&m_mutex);
ScopedLock sl(m_mutex);
m_cancelled = true;
m_condition.broadcast();
}

@ -9,7 +9,7 @@ class ScopedLock
public:
ScopedLock( const Mutex* const mutex );
ScopedLock( Mutex& mutex );
~ScopedLock();
private:
@ -17,7 +17,7 @@ private:
ScopedLock(const ScopedLock&);
ScopedLock& operator=(const ScopedLock&);
const Mutex* const m_mutex;
Mutex& m_mutex;
};

@ -2,15 +2,15 @@
#include "Common.hpp"
ScopedLock::ScopedLock( const Mutex* const mutex) : m_mutex(mutex)
ScopedLock::ScopedLock( Mutex& mutex) : m_mutex(mutex)
{
TRACE(this);
const_cast<Mutex*>(m_mutex)->lock();
m_mutex.lock();
}
ScopedLock::~ScopedLock()
{
TRACE(this);
const_cast<Mutex*>(m_mutex)->unlock();
m_mutex.unlock();
}

Loading…
Cancel
Save