diff options
author | Liam <byteslice@airmail.cc> | 2023-03-08 02:48:46 +0100 |
---|---|---|
committer | Liam <byteslice@airmail.cc> | 2023-03-08 02:51:29 +0100 |
commit | 1776448df2a023f6735b69e27b72664e02f448ee (patch) | |
tree | 51af858c5e60d432db36d876f1d791aded1115c9 /src/core/hle/kernel/k_scoped_scheduler_lock_and_sleep.h | |
parent | Merge pull request #9889 from Morph1984/time-is-ticking (diff) | |
download | yuzu-1776448df2a023f6735b69e27b72664e02f448ee.tar yuzu-1776448df2a023f6735b69e27b72664e02f448ee.tar.gz yuzu-1776448df2a023f6735b69e27b72664e02f448ee.tar.bz2 yuzu-1776448df2a023f6735b69e27b72664e02f448ee.tar.lz yuzu-1776448df2a023f6735b69e27b72664e02f448ee.tar.xz yuzu-1776448df2a023f6735b69e27b72664e02f448ee.tar.zst yuzu-1776448df2a023f6735b69e27b72664e02f448ee.zip |
Diffstat (limited to 'src/core/hle/kernel/k_scoped_scheduler_lock_and_sleep.h')
-rw-r--r-- | src/core/hle/kernel/k_scoped_scheduler_lock_and_sleep.h | 15 |
1 files changed, 11 insertions, 4 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 76db65a4d..14b83a819 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 @@ -13,16 +13,22 @@ namespace Kernel { class [[nodiscard]] KScopedSchedulerLockAndSleep { public: - explicit KScopedSchedulerLockAndSleep(KernelCore& kernel_, KThread* t, s64 timeout) - : kernel(kernel_), thread(t), timeout_tick(timeout) { + explicit KScopedSchedulerLockAndSleep(KernelCore& kernel_, KHardwareTimer** out_timer, + KThread* t, s64 timeout) + : kernel(kernel_), timeout_tick(timeout), thread(t), timer() { // Lock the scheduler. kernel.GlobalSchedulerContext().scheduler_lock.Lock(); + + // Set our timer only if the time is positive. + timer = (timeout_tick > 0) ? std::addressof(kernel.HardwareTimer()) : nullptr; + + *out_timer = timer; } ~KScopedSchedulerLockAndSleep() { // Register the sleep. if (timeout_tick > 0) { - kernel.HardwareTimer().RegisterTask(thread, timeout_tick); + timer->RegisterTask(thread, timeout_tick); } // Unlock the scheduler. @@ -35,8 +41,9 @@ public: private: KernelCore& kernel; - KThread* thread{}; s64 timeout_tick{}; + KThread* thread{}; + KHardwareTimer* timer{}; }; } // namespace Kernel |