summaryrefslogtreecommitdiffstats
path: root/src/core/hle
diff options
context:
space:
mode:
authorSubv <subv2112@gmail.com>2014-12-07 21:57:28 +0100
committerSubv <subv2112@gmail.com>2014-12-07 21:57:28 +0100
commitbc318c464bbe1a33e37312339d25c56021c444e8 (patch)
tree4d77ce76bcaea3d7afe54eae526beca2e315bf77 /src/core/hle
parentMutex: Release all held mutexes when a thread exits. (diff)
downloadyuzu-bc318c464bbe1a33e37312339d25c56021c444e8.tar
yuzu-bc318c464bbe1a33e37312339d25c56021c444e8.tar.gz
yuzu-bc318c464bbe1a33e37312339d25c56021c444e8.tar.bz2
yuzu-bc318c464bbe1a33e37312339d25c56021c444e8.tar.lz
yuzu-bc318c464bbe1a33e37312339d25c56021c444e8.tar.xz
yuzu-bc318c464bbe1a33e37312339d25c56021c444e8.tar.zst
yuzu-bc318c464bbe1a33e37312339d25c56021c444e8.zip
Diffstat (limited to 'src/core/hle')
-rw-r--r--src/core/hle/kernel/mutex.cpp31
1 files changed, 15 insertions, 16 deletions
diff --git a/src/core/hle/kernel/mutex.cpp b/src/core/hle/kernel/mutex.cpp
index 01de3c510..5a173e129 100644
--- a/src/core/hle/kernel/mutex.cpp
+++ b/src/core/hle/kernel/mutex.cpp
@@ -13,9 +13,6 @@
namespace Kernel {
-class Mutex;
-void MutexAcquireLock(Mutex* mutex, Handle thread = GetCurrentThreadHandle());
-
class Mutex : public Object {
public:
std::string GetTypeName() const override { return "Mutex"; }
@@ -30,18 +27,7 @@ public:
std::vector<Handle> waiting_threads; ///< Threads that are waiting for the mutex
std::string name; ///< Name of mutex (optional)
- ResultVal<bool> WaitSynchronization() override {
- bool wait = locked;
- if (locked) {
- Kernel::WaitCurrentThread(WAITTYPE_MUTEX, GetHandle());
- } else {
- // Lock the mutex when the first thread accesses it
- locked = true;
- MutexAcquireLock(this);
- }
-
- return MakeResult<bool>(wait);
- }
+ ResultVal<bool> WaitSynchronization() override;
};
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -54,7 +40,7 @@ static MutexMap g_mutex_held_locks;
* @param mutex Mutex that is to be acquired
* @param thread Thread that will acquired
*/
-void MutexAcquireLock(Mutex* mutex, Handle thread) {
+void MutexAcquireLock(Mutex* mutex, Handle thread = GetCurrentThreadHandle()) {
g_mutex_held_locks.insert(std::make_pair(thread, mutex->GetHandle()));
mutex->lock_thread = thread;
}
@@ -178,4 +164,17 @@ Handle CreateMutex(bool initial_locked, const std::string& name) {
return handle;
}
+ResultVal<bool> Mutex::WaitSynchronization() {
+ bool wait = locked;
+ if (locked) {
+ Kernel::WaitCurrentThread(WAITTYPE_MUTEX, GetHandle());
+ }
+ else {
+ // Lock the mutex when the first thread accesses it
+ locked = true;
+ MutexAcquireLock(this);
+ }
+
+ return MakeResult<bool>(wait);
+}
} // namespace