diff --git a/src/threading/event.cpp b/src/threading/event.cpp index 885e732c8..1b0c5ac07 100644 --- a/src/threading/event.cpp +++ b/src/threading/event.cpp @@ -28,7 +28,7 @@ DEALINGS IN THE SOFTWARE. void Event::wait() { - MutexAutoLock lock(mutex); + std::unique_lock lock(mutex); while (!notified) { cv.wait(lock); } @@ -38,7 +38,9 @@ void Event::wait() void Event::signal() { - MutexAutoLock lock(mutex); - notified = true; + { + std::lock_guard lock(mutex); + notified = true; + } cv.notify_one(); } diff --git a/src/threading/mutex_auto_lock.h b/src/threading/mutex_auto_lock.h index c809ff8f5..9a2522557 100644 --- a/src/threading/mutex_auto_lock.h +++ b/src/threading/mutex_auto_lock.h @@ -26,5 +26,8 @@ DEALINGS IN THE SOFTWARE. #pragma once #include -using MutexAutoLock = std::unique_lock; -using RecursiveMutexAutoLock = std::unique_lock; + +/// @deprecated use std::lock_guard directly +using MutexAutoLock = std::lock_guard; +/// @deprecated use std::lock_guard directly +using RecursiveMutexAutoLock = std::lock_guard; diff --git a/src/threading/thread.cpp b/src/threading/thread.cpp index f9e356ab7..a4405287d 100644 --- a/src/threading/thread.cpp +++ b/src/threading/thread.cpp @@ -117,7 +117,7 @@ bool Thread::start() // The mutex may already be locked if the thread is being restarted // FIXME: what if this fails, or if already locked by same thread? - MutexAutoLock sf_lock(m_start_finished_mutex, std::try_to_lock); + std::unique_lock sf_lock(m_start_finished_mutex, std::try_to_lock); try { m_thread_obj = new std::thread(threadProc, this); @@ -189,7 +189,7 @@ void Thread::threadProc(Thread *thr) // Wait for the thread that started this one to finish initializing the // thread handle so that getThreadId/getThreadHandle will work. - MutexAutoLock sf_lock(thr->m_start_finished_mutex); + std::unique_lock sf_lock(thr->m_start_finished_mutex); thr->m_retval = thr->run();