mirror of
https://github.com/minetest/minetest.git
synced 2024-11-20 14:43:45 +01:00
Alias MutexAutoLock to the simpler std::lock_guard
This commit is contained in:
parent
99b6315c1a
commit
244f4f285a
@ -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);
|
||||
{
|
||||
std::lock_guard lock(mutex);
|
||||
notified = true;
|
||||
}
|
||||
cv.notify_one();
|
||||
}
|
||||
|
@ -26,5 +26,8 @@ DEALINGS IN THE SOFTWARE.
|
||||
#pragma once
|
||||
|
||||
#include <mutex>
|
||||
using MutexAutoLock = std::unique_lock<std::mutex>;
|
||||
using RecursiveMutexAutoLock = std::unique_lock<std::recursive_mutex>;
|
||||
|
||||
/// @deprecated use std::lock_guard directly
|
||||
using MutexAutoLock = std::lock_guard<std::mutex>;
|
||||
/// @deprecated use std::lock_guard directly
|
||||
using RecursiveMutexAutoLock = std::lock_guard<std::recursive_mutex>;
|
||||
|
@ -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();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user