k_timer_task.h 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #pragma once
  4. #include "common/intrusive_red_black_tree.h"
  5. namespace Kernel {
  6. class KTimerTask : public Common::IntrusiveRedBlackTreeBaseNode<KTimerTask> {
  7. public:
  8. static constexpr int Compare(const KTimerTask& lhs, const KTimerTask& rhs) {
  9. if (lhs.GetTime() < rhs.GetTime()) {
  10. return -1;
  11. } else {
  12. return 1;
  13. }
  14. }
  15. constexpr explicit KTimerTask() = default;
  16. constexpr void SetTime(s64 t) {
  17. m_time = t;
  18. }
  19. constexpr s64 GetTime() const {
  20. return m_time;
  21. }
  22. // NOTE: This is virtual in Nintendo's kernel. Prior to 13.0.0, KWaitObject was also a
  23. // TimerTask; this is no longer the case. Since this is now KThread exclusive, we have
  24. // devirtualized (see inline declaration for this inside k_thread.h).
  25. void OnTimer();
  26. private:
  27. // Absolute time in nanoseconds
  28. s64 m_time{};
  29. };
  30. } // namespace Kernel