diff options
author | bunnei <bunneidev@gmail.com> | 2015-01-21 00:16:45 +0100 |
---|---|---|
committer | bunnei <bunneidev@gmail.com> | 2015-01-22 02:47:49 +0100 |
commit | 15b6a4d9add6b260a2a1a84ab6228addced4f851 (patch) | |
tree | e9934863ebd6483cabae0f6c280fab7e34eee32e /src/core/hle/kernel/mutex.cpp | |
parent | WaitObject: Renamed "Wait" to "ShouldWait", made "ShouldWait" and "Acquire" pure virtual. (diff) | |
download | yuzu-15b6a4d9add6b260a2a1a84ab6228addced4f851.tar yuzu-15b6a4d9add6b260a2a1a84ab6228addced4f851.tar.gz yuzu-15b6a4d9add6b260a2a1a84ab6228addced4f851.tar.bz2 yuzu-15b6a4d9add6b260a2a1a84ab6228addced4f851.tar.lz yuzu-15b6a4d9add6b260a2a1a84ab6228addced4f851.tar.xz yuzu-15b6a4d9add6b260a2a1a84ab6228addced4f851.tar.zst yuzu-15b6a4d9add6b260a2a1a84ab6228addced4f851.zip |
Diffstat (limited to 'src/core/hle/kernel/mutex.cpp')
-rw-r--r-- | src/core/hle/kernel/mutex.cpp | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/src/core/hle/kernel/mutex.cpp b/src/core/hle/kernel/mutex.cpp index 01d2263ff..355824e60 100644 --- a/src/core/hle/kernel/mutex.cpp +++ b/src/core/hle/kernel/mutex.cpp @@ -27,8 +27,8 @@ public: std::string name; ///< Name of mutex (optional) SharedPtr<Thread> current_thread; ///< Thread that has acquired the mutex - ResultVal<bool> ShouldWait() override; - ResultVal<bool> Acquire() override; + bool ShouldWait() override; + void Acquire() override; }; //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -159,20 +159,14 @@ Handle CreateMutex(bool initial_locked, const std::string& name) { return handle; } -ResultVal<bool> Mutex::ShouldWait() { - return MakeResult<bool>(locked && (current_thread != GetCurrentThread())); +bool Mutex::ShouldWait() { + return locked && current_thread != GetCurrentThread(); } -ResultVal<bool> Mutex::Acquire() { - bool res = false; - - if (!locked) { - // Lock the mutex when the first thread accesses it - locked = true; - res = true; - MutexAcquireLock(this); - } - - return MakeResult<bool>(res); +void Mutex::Acquire() { + _assert_msg_(Kernel, !ShouldWait(), "object unavailable!"); + locked = true; + MutexAcquireLock(this); } + } // namespace |