From aa01c57ae9d73e41b65d37860ca6fbb91caba33a Mon Sep 17 00:00:00 2001 From: bunnei Date: Sat, 17 Jan 2015 22:23:49 -0500 Subject: Kernel: Separate WaitSynchronization into Wait and Acquire methods. --- src/core/hle/kernel/mutex.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'src/core/hle/kernel/mutex.cpp') diff --git a/src/core/hle/kernel/mutex.cpp b/src/core/hle/kernel/mutex.cpp index 78063b8f1..37e7be4e7 100644 --- a/src/core/hle/kernel/mutex.cpp +++ b/src/core/hle/kernel/mutex.cpp @@ -26,7 +26,8 @@ public: Handle lock_thread; ///< Handle to thread that currently has mutex std::string name; ///< Name of mutex (optional) - ResultVal WaitSynchronization(unsigned index) override; + ResultVal Wait(unsigned index) override; + ResultVal Acquire() override; }; //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -155,17 +156,25 @@ Handle CreateMutex(bool initial_locked, const std::string& name) { return handle; } -ResultVal Mutex::WaitSynchronization(unsigned index) { - bool wait = locked; +ResultVal Mutex::Wait(unsigned index) { if (locked) { AddWaitingThread(GetCurrentThread()); Kernel::WaitCurrentThread_WaitSynchronization(WAITTYPE_MUTEX, this, index); - } else { + } + + return MakeResult(locked); +} + +ResultVal Mutex::Acquire() { + bool res = false; + + if (!locked) { // Lock the mutex when the first thread accesses it locked = true; + res = true; MutexAcquireLock(this); } - return MakeResult(wait); + return MakeResult(res); } } // namespace -- cgit v1.2.3