summaryrefslogtreecommitdiffstats
path: root/src/core/hle/kernel
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2020-12-04 07:43:35 +0100
committerbunnei <bunneidev@gmail.com>2020-12-06 09:03:24 +0100
commitb9b7e4f915ffc47836342a8741fe8e46a3bd619c (patch)
tree0c71e1762d640dd31fde0317335290057f28d213 /src/core/hle/kernel
parenthle: kernel: Migrate to KScopedSchedulerLock. (diff)
downloadyuzu-b9b7e4f915ffc47836342a8741fe8e46a3bd619c.tar
yuzu-b9b7e4f915ffc47836342a8741fe8e46a3bd619c.tar.gz
yuzu-b9b7e4f915ffc47836342a8741fe8e46a3bd619c.tar.bz2
yuzu-b9b7e4f915ffc47836342a8741fe8e46a3bd619c.tar.lz
yuzu-b9b7e4f915ffc47836342a8741fe8e46a3bd619c.tar.xz
yuzu-b9b7e4f915ffc47836342a8741fe8e46a3bd619c.tar.zst
yuzu-b9b7e4f915ffc47836342a8741fe8e46a3bd619c.zip
Diffstat (limited to 'src/core/hle/kernel')
-rw-r--r--src/core/hle/kernel/time_manager.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/core/hle/kernel/time_manager.cpp b/src/core/hle/kernel/time_manager.cpp
index aea53cdb0..79628e2b4 100644
--- a/src/core/hle/kernel/time_manager.cpp
+++ b/src/core/hle/kernel/time_manager.cpp
@@ -20,10 +20,16 @@ TimeManager::TimeManager(Core::System& system_) : system{system_} {
[this](std::uintptr_t thread_handle, std::chrono::nanoseconds) {
const KScopedSchedulerLock lock(system.Kernel());
const auto proper_handle = static_cast<Handle>(thread_handle);
- if (cancelled_events[proper_handle]) {
- return;
+
+ std::shared_ptr<Thread> thread;
+ {
+ std::lock_guard lock{mutex};
+ if (cancelled_events[proper_handle]) {
+ return;
+ }
+ thread = system.Kernel().RetrieveThreadFromGlobalHandleTable(proper_handle);
}
- auto thread = this->system.Kernel().RetrieveThreadFromGlobalHandleTable(proper_handle);
+
if (thread) {
// Thread can be null if process has exited
thread->OnWakeUp();
@@ -56,6 +62,7 @@ void TimeManager::UnscheduleTimeEvent(Handle event_handle) {
}
void TimeManager::CancelTimeEvent(Thread* time_task) {
+ std::lock_guard lock{mutex};
const Handle event_handle = time_task->GetGlobalHandle();
UnscheduleTimeEvent(event_handle);
}