summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/mutex.cpp
diff options
context:
space:
mode:
authorGravatar bunnei2015-01-20 18:16:45 -0500
committerGravatar bunnei2015-01-21 20:47:49 -0500
commit15b6a4d9add6b260a2a1a84ab6228addced4f851 (patch)
treee9934863ebd6483cabae0f6c280fab7e34eee32e /src/core/hle/kernel/mutex.cpp
parentWaitObject: Renamed "Wait" to "ShouldWait", made "ShouldWait" and "Acquire" p... (diff)
downloadyuzu-15b6a4d9add6b260a2a1a84ab6228addced4f851.tar.gz
yuzu-15b6a4d9add6b260a2a1a84ab6228addced4f851.tar.xz
yuzu-15b6a4d9add6b260a2a1a84ab6228addced4f851.zip
Kernel: Changed "ShouldWait" to return bool and "Acquire" to return void.
Diffstat (limited to 'src/core/hle/kernel/mutex.cpp')
-rw-r--r--src/core/hle/kernel/mutex.cpp24
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:
27 std::string name; ///< Name of mutex (optional) 27 std::string name; ///< Name of mutex (optional)
28 SharedPtr<Thread> current_thread; ///< Thread that has acquired the mutex 28 SharedPtr<Thread> current_thread; ///< Thread that has acquired the mutex
29 29
30 ResultVal<bool> ShouldWait() override; 30 bool ShouldWait() override;
31 ResultVal<bool> Acquire() override; 31 void Acquire() override;
32}; 32};
33 33
34//////////////////////////////////////////////////////////////////////////////////////////////////// 34////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -159,20 +159,14 @@ Handle CreateMutex(bool initial_locked, const std::string& name) {
159 return handle; 159 return handle;
160} 160}
161 161
162ResultVal<bool> Mutex::ShouldWait() { 162bool Mutex::ShouldWait() {
163 return MakeResult<bool>(locked && (current_thread != GetCurrentThread())); 163 return locked && current_thread != GetCurrentThread();
164} 164}
165 165
166ResultVal<bool> Mutex::Acquire() { 166void Mutex::Acquire() {
167 bool res = false; 167 _assert_msg_(Kernel, !ShouldWait(), "object unavailable!");
168 168 locked = true;
169 if (!locked) { 169 MutexAcquireLock(this);
170 // Lock the mutex when the first thread accesses it
171 locked = true;
172 res = true;
173 MutexAcquireLock(this);
174 }
175
176 return MakeResult<bool>(res);
177} 170}
171
178} // namespace 172} // namespace