From dfc0f2ae007e186c724b871c7df27f2bf43f76d6 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 26 Aug 2015 23:02:45 +0100 Subject: Small fix for cEvent Don't bother using atomics since a synchronisation primitive is already being used. --- src/OSSupport/Event.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src/OSSupport/Event.cpp') diff --git a/src/OSSupport/Event.cpp b/src/OSSupport/Event.cpp index 4c2adea3c..be2803451 100644 --- a/src/OSSupport/Event.cpp +++ b/src/OSSupport/Event.cpp @@ -25,9 +25,9 @@ void cEvent::Wait(void) { { std::unique_lock Lock(m_Mutex); - m_CondVar.wait(Lock, [this](){ return m_ShouldContinue.load(); }); + m_CondVar.wait(Lock, [this](){ return m_ShouldContinue; }); + m_ShouldContinue = false; } - m_ShouldContinue = false; } @@ -40,9 +40,9 @@ bool cEvent::Wait(unsigned a_TimeoutMSec) bool Result; { std::unique_lock Lock(m_Mutex); // We assume that this lock is acquired without much delay - we are the only user of the mutex - Result = m_CondVar.wait_until(Lock, dst, [this](){ return m_ShouldContinue.load(); }); + Result = m_CondVar.wait_until(Lock, dst, [this](){ return m_ShouldContinue; }); + m_ShouldContinue = false; } - m_ShouldContinue = false; return Result; } @@ -52,7 +52,10 @@ bool cEvent::Wait(unsigned a_TimeoutMSec) void cEvent::Set(void) { - m_ShouldContinue = true; + { + std::unique_lock Lock(m_Mutex); + m_ShouldContinue = true; + } m_CondVar.notify_one(); } @@ -61,7 +64,10 @@ void cEvent::Set(void) void cEvent::SetAll(void) { - m_ShouldContinue = true; + { + std::unique_lock Lock(m_Mutex); + m_ShouldContinue = true; + } m_CondVar.notify_all(); } -- cgit v1.2.3