summaryrefslogtreecommitdiffstats
path: root/src/core/hle/kernel/k_timer_task.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/hle/kernel/k_timer_task.h')
-rw-r--r--src/core/hle/kernel/k_timer_task.h40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/core/hle/kernel/k_timer_task.h b/src/core/hle/kernel/k_timer_task.h
new file mode 100644
index 000000000..66f0a5a90
--- /dev/null
+++ b/src/core/hle/kernel/k_timer_task.h
@@ -0,0 +1,40 @@
+// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#include "common/intrusive_red_black_tree.h"
+
+namespace Kernel {
+
+class KTimerTask : public Common::IntrusiveRedBlackTreeBaseNode<KTimerTask> {
+public:
+ static constexpr int Compare(const KTimerTask& lhs, const KTimerTask& rhs) {
+ if (lhs.GetTime() < rhs.GetTime()) {
+ return -1;
+ } else {
+ return 1;
+ }
+ }
+
+ constexpr explicit KTimerTask() = default;
+
+ constexpr void SetTime(s64 t) {
+ m_time = t;
+ }
+
+ constexpr s64 GetTime() const {
+ return m_time;
+ }
+
+ // NOTE: This is virtual in Nintendo's kernel. Prior to 13.0.0, KWaitObject was also a
+ // TimerTask; this is no longer the case. Since this is now KThread exclusive, we have
+ // devirtualized (see inline declaration for this inside k_thread.h).
+ void OnTimer();
+
+private:
+ // Absolute time in nanoseconds
+ s64 m_time{};
+};
+
+} // namespace Kernel