summaryrefslogtreecommitdiffstats
path: root/src/core/hle/kernel/k_timer_task.h
blob: 66f0a5a908ba0d229bb61244443dd38e40ac040b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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