summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel
diff options
context:
space:
mode:
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_} {
20 [this](std::uintptr_t thread_handle, std::chrono::nanoseconds) { 20 [this](std::uintptr_t thread_handle, std::chrono::nanoseconds) {
21 const KScopedSchedulerLock lock(system.Kernel()); 21 const KScopedSchedulerLock lock(system.Kernel());
22 const auto proper_handle = static_cast<Handle>(thread_handle); 22 const auto proper_handle = static_cast<Handle>(thread_handle);
23 if (cancelled_events[proper_handle]) { 23
24 return; 24 std::shared_ptr<Thread> thread;
25 {
26 std::lock_guard lock{mutex};
27 if (cancelled_events[proper_handle]) {
28 return;
29 }
30 thread = system.Kernel().RetrieveThreadFromGlobalHandleTable(proper_handle);
25 } 31 }
26 auto thread = this->system.Kernel().RetrieveThreadFromGlobalHandleTable(proper_handle); 32
27 if (thread) { 33 if (thread) {
28 // Thread can be null if process has exited 34 // Thread can be null if process has exited
29 thread->OnWakeUp(); 35 thread->OnWakeUp();
@@ -56,6 +62,7 @@ void TimeManager::UnscheduleTimeEvent(Handle event_handle) {
56} 62}
57 63
58void TimeManager::CancelTimeEvent(Thread* time_task) { 64void TimeManager::CancelTimeEvent(Thread* time_task) {
65 std::lock_guard lock{mutex};
59 const Handle event_handle = time_task->GetGlobalHandle(); 66 const Handle event_handle = time_task->GetGlobalHandle();
60 UnscheduleTimeEvent(event_handle); 67 UnscheduleTimeEvent(event_handle);
61} 68}