diff --git a/include/ConcurrentQueue.hpp b/include/ConcurrentQueue.hpp index 161edbb..075492d 100644 --- a/include/ConcurrentQueue.hpp +++ b/include/ConcurrentQueue.hpp @@ -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(); } diff --git a/include/ScopedLock.hpp b/include/ScopedLock.hpp index 85c551c..670aed9 100644 --- a/include/ScopedLock.hpp +++ b/include/ScopedLock.hpp @@ -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; }; diff --git a/src/ScopedLock.cpp b/src/ScopedLock.cpp index 05e8b22..8a3d198 100644 --- a/src/ScopedLock.cpp +++ b/src/ScopedLock.cpp @@ -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(m_mutex)->lock(); + m_mutex.lock(); } ScopedLock::~ScopedLock() { TRACE(this); - const_cast(m_mutex)->unlock(); + m_mutex.unlock(); }