2019-12-13 10:21:43 +01:00
|
|
|
/*
|
2021-10-04 21:59:10 +02:00
|
|
|
* Copyright (c) Atmosphère-NX
|
2019-12-13 10:21:43 +01:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms and conditions of the GNU General Public License,
|
|
|
|
* version 2, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
* more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
#pragma once
|
2020-01-31 00:29:51 +01:00
|
|
|
#include <mesosphere/kern_common.hpp>
|
2019-12-13 10:21:43 +01:00
|
|
|
|
|
|
|
namespace ams::kern {
|
|
|
|
|
2020-01-29 23:26:24 +01:00
|
|
|
class KTimerTask : public util::IntrusiveRedBlackTreeBaseNode<KTimerTask> {
|
|
|
|
private:
|
2020-12-18 02:18:47 +01:00
|
|
|
s64 m_time;
|
2020-01-29 23:26:24 +01:00
|
|
|
public:
|
|
|
|
static constexpr ALWAYS_INLINE int Compare(const KTimerTask &lhs, const KTimerTask &rhs) {
|
|
|
|
if (lhs.GetTime() < rhs.GetTime()) {
|
|
|
|
return -1;
|
|
|
|
} else {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public:
|
2020-12-18 02:18:47 +01:00
|
|
|
constexpr ALWAYS_INLINE KTimerTask() : m_time(0) { /* ... */ }
|
2019-12-13 10:21:43 +01:00
|
|
|
|
2020-01-29 23:26:24 +01:00
|
|
|
constexpr ALWAYS_INLINE void SetTime(s64 t) {
|
2020-12-18 02:18:47 +01:00
|
|
|
m_time = t;
|
2020-01-29 23:26:24 +01:00
|
|
|
}
|
2019-12-13 10:21:43 +01:00
|
|
|
|
2020-01-29 23:26:24 +01:00
|
|
|
constexpr ALWAYS_INLINE s64 GetTime() const {
|
2020-12-18 02:18:47 +01:00
|
|
|
return m_time;
|
2020-01-29 23:26:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual void OnTimer() = 0;
|
2019-12-13 10:21:43 +01:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|