diff options
| author | 2014-12-28 21:11:55 -0500 | |
|---|---|---|
| committer | 2014-12-28 21:11:55 -0500 | |
| commit | 77363d9590ed544cf714f26c575e98b7858e18e1 (patch) | |
| tree | a48225a3b62bb3d72d94289b6e34326cbed4f5cc /src/core/hle/kernel/mutex.cpp | |
| parent | Merge pull request #357 from bunnei/dyncom-pkhbt-pkhtb (diff) | |
| parent | Kernel: New handle manager (diff) | |
| download | yuzu-77363d9590ed544cf714f26c575e98b7858e18e1.tar.gz yuzu-77363d9590ed544cf714f26c575e98b7858e18e1.tar.xz yuzu-77363d9590ed544cf714f26c575e98b7858e18e1.zip | |
Merge pull request #331 from yuriks/handle-reform
New Handle manager
Diffstat (limited to 'src/core/hle/kernel/mutex.cpp')
| -rw-r--r-- | src/core/hle/kernel/mutex.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/core/hle/kernel/mutex.cpp b/src/core/hle/kernel/mutex.cpp index 5a18af114..558068c79 100644 --- a/src/core/hle/kernel/mutex.cpp +++ b/src/core/hle/kernel/mutex.cpp | |||
| @@ -18,8 +18,8 @@ public: | |||
| 18 | std::string GetTypeName() const override { return "Mutex"; } | 18 | std::string GetTypeName() const override { return "Mutex"; } |
| 19 | std::string GetName() const override { return name; } | 19 | std::string GetName() const override { return name; } |
| 20 | 20 | ||
| 21 | static Kernel::HandleType GetStaticHandleType() { return Kernel::HandleType::Mutex; } | 21 | static const HandleType HANDLE_TYPE = HandleType::Mutex; |
| 22 | Kernel::HandleType GetHandleType() const override { return Kernel::HandleType::Mutex; } | 22 | HandleType GetHandleType() const override { return HANDLE_TYPE; } |
| 23 | 23 | ||
| 24 | bool initial_locked; ///< Initial lock state when mutex was created | 24 | bool initial_locked; ///< Initial lock state when mutex was created |
| 25 | bool locked; ///< Current locked state | 25 | bool locked; ///< Current locked state |
| @@ -87,7 +87,7 @@ void ReleaseThreadMutexes(Handle thread) { | |||
| 87 | 87 | ||
| 88 | // Release every mutex that the thread holds, and resume execution on the waiting threads | 88 | // Release every mutex that the thread holds, and resume execution on the waiting threads |
| 89 | for (MutexMap::iterator iter = locked.first; iter != locked.second; ++iter) { | 89 | for (MutexMap::iterator iter = locked.first; iter != locked.second; ++iter) { |
| 90 | Mutex* mutex = g_object_pool.GetFast<Mutex>(iter->second); | 90 | Mutex* mutex = g_handle_table.Get<Mutex>(iter->second); |
| 91 | ResumeWaitingThread(mutex); | 91 | ResumeWaitingThread(mutex); |
| 92 | } | 92 | } |
| 93 | 93 | ||
| @@ -115,7 +115,7 @@ bool ReleaseMutex(Mutex* mutex) { | |||
| 115 | * @param handle Handle to mutex to release | 115 | * @param handle Handle to mutex to release |
| 116 | */ | 116 | */ |
| 117 | ResultCode ReleaseMutex(Handle handle) { | 117 | ResultCode ReleaseMutex(Handle handle) { |
| 118 | Mutex* mutex = Kernel::g_object_pool.Get<Mutex>(handle); | 118 | Mutex* mutex = Kernel::g_handle_table.Get<Mutex>(handle); |
| 119 | if (mutex == nullptr) return InvalidHandle(ErrorModule::Kernel); | 119 | if (mutex == nullptr) return InvalidHandle(ErrorModule::Kernel); |
| 120 | 120 | ||
| 121 | if (!ReleaseMutex(mutex)) { | 121 | if (!ReleaseMutex(mutex)) { |
| @@ -136,7 +136,8 @@ ResultCode ReleaseMutex(Handle handle) { | |||
| 136 | */ | 136 | */ |
| 137 | Mutex* CreateMutex(Handle& handle, bool initial_locked, const std::string& name) { | 137 | Mutex* CreateMutex(Handle& handle, bool initial_locked, const std::string& name) { |
| 138 | Mutex* mutex = new Mutex; | 138 | Mutex* mutex = new Mutex; |
| 139 | handle = Kernel::g_object_pool.Create(mutex); | 139 | // TODO(yuriks): Fix error reporting |
| 140 | handle = Kernel::g_handle_table.Create(mutex).ValueOr(INVALID_HANDLE); | ||
| 140 | 141 | ||
| 141 | mutex->locked = mutex->initial_locked = initial_locked; | 142 | mutex->locked = mutex->initial_locked = initial_locked; |
| 142 | mutex->name = name; | 143 | mutex->name = name; |