1
0
Fork 0
mirror of https://github.com/Atmosphere-NX/Atmosphere.git synced 2024-12-01 00:02:16 +00:00
Atmosphere/libraries/libstratosphere/include/stratosphere/os/os_event.hpp

73 lines
2 KiB
C++
Raw Normal View History

/*
* Copyright (c) Atmosphère-NX
*
* 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-04-08 10:21:35 +01:00
#include <vapours.hpp>
#include <stratosphere/os/os_event_common.hpp>
#include <stratosphere/os/os_event_types.hpp>
#include <stratosphere/os/os_event_api.hpp>
namespace ams::os {
class Event {
NON_COPYABLE(Event);
NON_MOVEABLE(Event);
private:
2021-10-10 08:14:06 +01:00
EventType m_event;
public:
2020-04-08 10:21:35 +01:00
explicit Event(EventClearMode clear_mode) {
2021-10-10 08:14:06 +01:00
InitializeEvent(std::addressof(m_event), false, clear_mode);
2020-04-08 10:21:35 +01:00
}
~Event() {
2021-10-10 08:14:06 +01:00
FinalizeEvent(std::addressof(m_event));
2020-04-08 10:21:35 +01:00
}
void Wait() {
2021-10-10 08:14:06 +01:00
return WaitEvent(std::addressof(m_event));
2020-04-08 10:21:35 +01:00
}
bool TryWait() {
2021-10-10 08:14:06 +01:00
return TryWaitEvent(std::addressof(m_event));
2020-04-08 10:21:35 +01:00
}
bool TimedWait(TimeSpan timeout) {
2021-10-10 08:14:06 +01:00
return TimedWaitEvent(std::addressof(m_event), timeout);
2020-04-08 10:21:35 +01:00
}
void Signal() {
2021-10-10 08:14:06 +01:00
return SignalEvent(std::addressof(m_event));
2020-04-08 10:21:35 +01:00
}
void Clear() {
2021-10-10 08:14:06 +01:00
return ClearEvent(std::addressof(m_event));
2020-04-08 10:21:35 +01:00
}
operator EventType &() {
2021-10-10 08:14:06 +01:00
return m_event;
2020-04-08 10:21:35 +01:00
}
operator const EventType &() const {
2021-10-10 08:14:06 +01:00
return m_event;
2020-04-08 10:21:35 +01:00
}
EventType *GetBase() {
2021-10-10 08:14:06 +01:00
return std::addressof(m_event);
2020-04-08 10:21:35 +01:00
}
};
}