1
0
Fork 0
mirror of https://github.com/Atmosphere-NX/Atmosphere.git synced 2024-12-27 04:36:04 +00:00
Atmosphere/libraries/libstratosphere/include/stratosphere/os/os_timer_event.hpp

80 lines
2.3 KiB
C++
Raw Normal View History

2020-04-29 08:41:51 +01:00
/*
* Copyright (c) Atmosphère-NX
2020-04-29 08:41:51 +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
#include <vapours.hpp>
#include <stratosphere/os/os_timer_event_types.hpp>
#include <stratosphere/os/os_timer_event_api.hpp>
namespace ams::os {
class TimerEvent {
NON_COPYABLE(TimerEvent);
NON_MOVEABLE(TimerEvent);
private:
2021-10-10 08:14:06 +01:00
TimerEventType m_event;
2020-04-29 08:41:51 +01:00
public:
explicit TimerEvent(EventClearMode clear_mode) {
2021-10-10 08:14:06 +01:00
InitializeTimerEvent(std::addressof(m_event), clear_mode);
2020-04-29 08:41:51 +01:00
}
~TimerEvent() {
2021-10-10 08:14:06 +01:00
FinalizeTimerEvent(std::addressof(m_event));
2020-04-29 08:41:51 +01:00
}
void StartOneShot(TimeSpan first_time) {
2021-10-10 08:14:06 +01:00
return StartOneShotTimerEvent(std::addressof(m_event), first_time);
2020-04-29 08:41:51 +01:00
}
void StartPeriodic(TimeSpan first_time, TimeSpan interval) {
2021-10-10 08:14:06 +01:00
return StartPeriodicTimerEvent(std::addressof(m_event), first_time, interval);
2020-04-29 08:41:51 +01:00
}
void Stop() {
2021-10-10 08:14:06 +01:00
return StopTimerEvent(std::addressof(m_event));
2020-04-29 08:41:51 +01:00
}
void Wait() {
2021-10-10 08:14:06 +01:00
return WaitTimerEvent(std::addressof(m_event));
2020-04-29 08:41:51 +01:00
}
bool TryWait() {
2021-10-10 08:14:06 +01:00
return TryWaitTimerEvent(std::addressof(m_event));
2020-04-29 08:41:51 +01:00
}
void Signal() {
2021-10-10 08:14:06 +01:00
return SignalTimerEvent(std::addressof(m_event));
2020-04-29 08:41:51 +01:00
}
void Clear() {
2021-10-10 08:14:06 +01:00
return ClearTimerEvent(std::addressof(m_event));
2020-04-29 08:41:51 +01:00
}
operator TimerEventType &() {
2021-10-10 08:14:06 +01:00
return m_event;
2020-04-29 08:41:51 +01:00
}
operator const TimerEventType &() const {
2021-10-10 08:14:06 +01:00
return m_event;
2020-04-29 08:41:51 +01:00
}
TimerEventType *GetBase() {
2021-10-10 08:14:06 +01:00
return std::addressof(m_event);
2020-04-29 08:41:51 +01:00
}
};
}