mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-06-02 23:59:49 -04:00
os: oh geez look at the time
This commit is contained in:
parent
72f1e85aba
commit
f670949ca9
9 changed files with 621 additions and 0 deletions
|
@ -33,6 +33,7 @@
|
|||
#include <stratosphere/os/os_event.hpp>
|
||||
#include <stratosphere/os/os_system_event.hpp>
|
||||
#include <stratosphere/os/os_interrupt_event.hpp>
|
||||
#include <stratosphere/os/os_timer_event.hpp>
|
||||
#include <stratosphere/os/os_thread_local_storage_api.hpp>
|
||||
#include <stratosphere/os/os_thread.hpp>
|
||||
#include <stratosphere/os/os_message_queue.hpp>
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2020 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
|
||||
#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:
|
||||
TimerEventType event;
|
||||
public:
|
||||
explicit TimerEvent(EventClearMode clear_mode) {
|
||||
InitializeTimerEvent(std::addressof(this->event), clear_mode);
|
||||
}
|
||||
|
||||
~TimerEvent() {
|
||||
FinalizeTimerEvent(std::addressof(this->event));
|
||||
}
|
||||
|
||||
void StartOneShot(TimeSpan first_time) {
|
||||
return StartOneShotTimerEvent(std::addressof(this->event), first_time);
|
||||
}
|
||||
|
||||
void StartPeriodic(TimeSpan first_time, TimeSpan interval) {
|
||||
return StartPeriodicTimerEvent(std::addressof(this->event), first_time, interval);
|
||||
}
|
||||
|
||||
void Stop() {
|
||||
return StopTimerEvent(std::addressof(this->event));
|
||||
}
|
||||
|
||||
void Wait() {
|
||||
return WaitTimerEvent(std::addressof(this->event));
|
||||
}
|
||||
|
||||
bool TryWait() {
|
||||
return TryWaitTimerEvent(std::addressof(this->event));
|
||||
}
|
||||
|
||||
void Signal() {
|
||||
return SignalTimerEvent(std::addressof(this->event));
|
||||
}
|
||||
|
||||
void Clear() {
|
||||
return ClearTimerEvent(std::addressof(this->event));
|
||||
}
|
||||
|
||||
operator TimerEventType &() {
|
||||
return this->event;
|
||||
}
|
||||
|
||||
operator const TimerEventType &() const {
|
||||
return this->event;
|
||||
}
|
||||
|
||||
TimerEventType *GetBase() {
|
||||
return std::addressof(this->event);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2020 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
|
||||
#include <vapours.hpp>
|
||||
#include <stratosphere/os/os_event_common.hpp>
|
||||
|
||||
namespace ams::os {
|
||||
|
||||
struct TimerEventType;
|
||||
struct WaitableHolderType;
|
||||
|
||||
void InitializeTimerEvent(TimerEventType *event, EventClearMode clear_mode);
|
||||
void FinalizeTimerEvent(TimerEventType *event);
|
||||
|
||||
void StartOneShotTimerEvent(TimerEventType *event, TimeSpan first_time);
|
||||
void StartPeriodicTimerEvent(TimerEventType *event, TimeSpan first_time, TimeSpan interval);
|
||||
void StopTimerEvent(TimerEventType *event);
|
||||
|
||||
void WaitTimerEvent(TimerEventType *event);
|
||||
bool TryWaitTimerEvent(TimerEventType *event);
|
||||
|
||||
void SignalTimerEvent(TimerEventType *event);
|
||||
void ClearTimerEvent(TimerEventType *event);
|
||||
|
||||
void InitializeWaitableHolder(WaitableHolderType *waitable_holder, TimerEventType *event);
|
||||
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2020 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
|
||||
#include <vapours.hpp>
|
||||
#include <stratosphere/os/os_event_common.hpp>
|
||||
#include <stratosphere/os/impl/os_internal_critical_section.hpp>
|
||||
#include <stratosphere/os/impl/os_internal_condition_variable.hpp>
|
||||
|
||||
namespace ams::os {
|
||||
|
||||
namespace impl {
|
||||
|
||||
class WaitableObjectList;
|
||||
|
||||
}
|
||||
|
||||
struct TimerEventType {
|
||||
using TimeSpanStorage = TYPED_STORAGE(TimeSpan);
|
||||
|
||||
enum State {
|
||||
State_NotInitialized = 0,
|
||||
State_Initialized = 1,
|
||||
};
|
||||
|
||||
enum TimerState {
|
||||
TimerState_Stop = 0,
|
||||
TimerState_OneShot = 1,
|
||||
TimerState_Periodic = 2,
|
||||
};
|
||||
|
||||
util::TypedStorage<impl::WaitableObjectList, sizeof(util::IntrusiveListNode), alignof(util::IntrusiveListNode)> waitable_object_list_storage;
|
||||
|
||||
u8 state;
|
||||
u8 clear_mode;
|
||||
bool signaled;
|
||||
u8 timer_state;
|
||||
u32 broadcast_counter_low;
|
||||
u32 broadcast_counter_high;
|
||||
|
||||
TimeSpanStorage next_time_to_wakeup;
|
||||
TimeSpanStorage first;
|
||||
TimeSpanStorage interval;
|
||||
|
||||
impl::InternalCriticalSectionStorage cs_timer_event;
|
||||
impl::InternalConditionVariableStorage cv_signaled;
|
||||
};
|
||||
static_assert(std::is_trivial<TimerEventType>::value);
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue