aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/hle/kernel/mutex.cpp
diff options
context:
space:
mode:
authorGravatar bunnei <bunneidev@gmail.com>2015-01-17 22:23:49 -0500
committerGravatar bunnei <bunneidev@gmail.com>2015-01-21 19:10:24 -0500
commitaa01c57ae9d73e41b65d37860ca6fbb91caba33a (patch)
tree904936860b1e8319ec5edc3a1e0e6c2c12f01d9f /src/core/hle/kernel/mutex.cpp
parent627e96fc15f99eea0f1c5ccdb46d85cadb3efd69 (diff)
Kernel: Separate WaitSynchronization into Wait and Acquire methods.
Diffstat (limited to 'src/core/hle/kernel/mutex.cpp')
-rw-r--r--src/core/hle/kernel/mutex.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/core/hle/kernel/mutex.cpp b/src/core/hle/kernel/mutex.cpp
index 78063b8f..37e7be4e 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<bool> WaitSynchronization(unsigned index) override;
+ ResultVal<bool> Wait(unsigned index) override;
+ ResultVal<bool> Acquire() override;
};
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -155,17 +156,25 @@ Handle CreateMutex(bool initial_locked, const std::string& name) {
return handle;
}
-ResultVal<bool> Mutex::WaitSynchronization(unsigned index) {
- bool wait = locked;
+ResultVal<bool> Mutex::Wait(unsigned index) {
if (locked) {
AddWaitingThread(GetCurrentThread());
Kernel::WaitCurrentThread_WaitSynchronization(WAITTYPE_MUTEX, this, index);
- } else {
+ }
+
+ return MakeResult<bool>(locked);
+}
+
+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>(wait);
+ return MakeResult<bool>(res);
}
} // namespace