summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2020-12-04 07:44:06 +0100
committerbunnei <bunneidev@gmail.com>2020-12-06 09:03:24 +0100
commitbc59ca92b6540efbcf45baab79d0f498eb103f30 (patch)
treeafb08107e4333dcafbb7a64d7f503399fe63fce3
parentkernel: time_manager: Add missing lock guards. (diff)
downloadyuzu-bc59ca92b6540efbcf45baab79d0f498eb103f30.tar
yuzu-bc59ca92b6540efbcf45baab79d0f498eb103f30.tar.gz
yuzu-bc59ca92b6540efbcf45baab79d0f498eb103f30.tar.bz2
yuzu-bc59ca92b6540efbcf45baab79d0f498eb103f30.tar.lz
yuzu-bc59ca92b6540efbcf45baab79d0f498eb103f30.tar.xz
yuzu-bc59ca92b6540efbcf45baab79d0f498eb103f30.tar.zst
yuzu-bc59ca92b6540efbcf45baab79d0f498eb103f30.zip
-rw-r--r--src/core/hle/kernel/k_scoped_scheduler_lock_and_sleep.h20
1 files changed, 7 insertions, 13 deletions
diff --git a/src/core/hle/kernel/k_scoped_scheduler_lock_and_sleep.h b/src/core/hle/kernel/k_scoped_scheduler_lock_and_sleep.h
index f11a62216..16f470923 100644
--- a/src/core/hle/kernel/k_scoped_scheduler_lock_and_sleep.h
+++ b/src/core/hle/kernel/k_scoped_scheduler_lock_and_sleep.h
@@ -8,6 +8,7 @@
#pragma once
#include "common/common_types.h"
+#include "core/hle/kernel/handle_table.h"
#include "core/hle/kernel/kernel.h"
#include "core/hle/kernel/thread.h"
#include "core/hle/kernel/time_manager.h"
@@ -17,20 +18,16 @@ namespace Kernel {
class KScopedSchedulerLockAndSleep {
private:
KernelCore& kernel;
- s64 timeout_tick{};
+ Handle& event_handle;
Thread* thread{};
- Handle* event_handle{};
+ s64 timeout_tick{};
public:
- explicit KScopedSchedulerLockAndSleep(KernelCore& kernel, Thread* t, s64 timeout)
- : kernel(kernel), timeout_tick(timeout), thread(t) {
- /* Lock the scheduler. */
- kernel.GlobalSchedulerContext().scheduler_lock.Lock();
- }
-
explicit KScopedSchedulerLockAndSleep(KernelCore& kernel, Handle& event_handle, Thread* t,
s64 timeout)
- : kernel(kernel), event_handle(&event_handle), timeout_tick(timeout), thread(t) {
+ : kernel(kernel), event_handle(event_handle), thread(t), timeout_tick(timeout) {
+ event_handle = InvalidHandle;
+
/* Lock the scheduler. */
kernel.GlobalSchedulerContext().scheduler_lock.Lock();
}
@@ -38,10 +35,7 @@ public:
~KScopedSchedulerLockAndSleep() {
/* Register the sleep. */
if (this->timeout_tick > 0) {
- auto& time_manager = kernel.TimeManager();
- Handle handle{};
- time_manager.ScheduleTimeEvent(event_handle ? *event_handle : handle, this->thread,
- this->timeout_tick);
+ kernel.TimeManager().ScheduleTimeEvent(event_handle, this->thread, this->timeout_tick);
}
/* Unlock the scheduler. */