mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-05-25 12:14:24 -04:00
os: refactor/rewrite entire namespace.
This commit is contained in:
parent
6193283f03
commit
065485b971
181 changed files with 5353 additions and 1929 deletions
|
@ -15,66 +15,99 @@
|
|||
*/
|
||||
|
||||
#pragma once
|
||||
#include "os_event.hpp"
|
||||
#include <stratosphere/os/os_event_common.hpp>
|
||||
#include <stratosphere/os/os_system_event_types.hpp>
|
||||
#include <stratosphere/os/os_system_event_api.hpp>
|
||||
|
||||
namespace ams::os {
|
||||
|
||||
class WaitableHolder;
|
||||
|
||||
namespace impl {
|
||||
|
||||
class InterProcessEvent;
|
||||
|
||||
}
|
||||
|
||||
enum class SystemEventState {
|
||||
Uninitialized,
|
||||
Event,
|
||||
InterProcessEvent,
|
||||
};
|
||||
|
||||
class SystemEvent {
|
||||
friend class WaitableHolder;
|
||||
NON_COPYABLE(SystemEvent);
|
||||
NON_MOVEABLE(SystemEvent);
|
||||
private:
|
||||
union {
|
||||
util::TypedStorage<Event, sizeof(Event), alignof(Event)> storage_for_event;
|
||||
util::TypedStorage<impl::InterProcessEvent, 3 * sizeof(Handle), alignof(Handle)> storage_for_inter_process_event;
|
||||
};
|
||||
SystemEventState state;
|
||||
private:
|
||||
Event &GetEvent();
|
||||
const Event &GetEvent() const;
|
||||
impl::InterProcessEvent &GetInterProcessEvent();
|
||||
const impl::InterProcessEvent &GetInterProcessEvent() const;
|
||||
SystemEventType system_event;
|
||||
public:
|
||||
SystemEvent() : state(SystemEventState::Uninitialized) { /* ... */ }
|
||||
SystemEvent(bool inter_process, bool autoclear = true);
|
||||
SystemEvent(Handle read_handle, bool manage_read_handle, Handle write_handle, bool manage_write_handle, bool autoclear = true);
|
||||
SystemEvent(Handle read_handle, bool manage_read_handle, bool autoclear = true) : SystemEvent(read_handle, manage_read_handle, INVALID_HANDLE, false, autoclear) { /* ... */ }
|
||||
~SystemEvent();
|
||||
|
||||
Result InitializeAsEvent(bool autoclear = true);
|
||||
Result InitializeAsInterProcessEvent(bool autoclear = true);
|
||||
void AttachHandles(Handle read_handle, bool manage_read_handle, Handle write_handle, bool manage_write_handle, bool autoclear = true);
|
||||
void AttachReadableHandle(Handle read_handle, bool manage_read_handle, bool autoclear = true);
|
||||
void AttachWritableHandle(Handle write_handle, bool manage_write_handle, bool autoclear = true);
|
||||
Handle DetachReadableHandle();
|
||||
Handle DetachWritableHandle();
|
||||
Handle GetReadableHandle() const;
|
||||
Handle GetWritableHandle() const;
|
||||
void Finalize();
|
||||
|
||||
SystemEventState GetState() const {
|
||||
return this->state;
|
||||
SystemEvent() {
|
||||
this->system_event.state = SystemEventType::State_NotInitialized;
|
||||
}
|
||||
|
||||
void Signal();
|
||||
void Reset();
|
||||
void Wait();
|
||||
bool TryWait();
|
||||
bool TimedWait(u64 ns);
|
||||
explicit SystemEvent(EventClearMode clear_mode, bool inter_process) {
|
||||
R_ABORT_UNLESS(CreateSystemEvent(std::addressof(this->system_event), clear_mode, inter_process));
|
||||
}
|
||||
|
||||
explicit SystemEvent(Handle read_handle, bool manage_read_handle, Handle write_handle, bool manage_write_handle, EventClearMode clear_mode) {
|
||||
AttachSystemEvent(std::addressof(this->system_event), read_handle, manage_read_handle, write_handle, manage_write_handle, clear_mode);
|
||||
}
|
||||
|
||||
~SystemEvent() {
|
||||
if (this->system_event.state == SystemEventType::State_NotInitialized) {
|
||||
return;
|
||||
}
|
||||
DestroySystemEvent(std::addressof(this->system_event));
|
||||
}
|
||||
|
||||
void Attach(Handle read_handle, bool manage_read_handle, Handle write_handle, bool manage_write_handle, EventClearMode clear_mode) {
|
||||
AMS_ABORT_UNLESS(this->system_event.state == SystemEventType::State_NotInitialized);
|
||||
return AttachSystemEvent(std::addressof(this->system_event), read_handle, manage_read_handle, write_handle, manage_write_handle, clear_mode);
|
||||
}
|
||||
|
||||
void AttachReadableHandle(Handle read_handle, bool manage_read_handle, EventClearMode clear_mode) {
|
||||
AMS_ABORT_UNLESS(this->system_event.state == SystemEventType::State_NotInitialized);
|
||||
return AttachReadableHandleToSystemEvent(std::addressof(this->system_event), read_handle, manage_read_handle, clear_mode);
|
||||
}
|
||||
|
||||
void AttachWritableHandle(Handle write_handle, bool manage_write_handle, EventClearMode clear_mode) {
|
||||
AMS_ABORT_UNLESS(this->system_event.state == SystemEventType::State_NotInitialized);
|
||||
return AttachWritableHandleToSystemEvent(std::addressof(this->system_event), write_handle, manage_write_handle, clear_mode);
|
||||
}
|
||||
|
||||
Handle DetachReadableHandle() {
|
||||
return DetachReadableHandleOfSystemEvent(std::addressof(this->system_event));
|
||||
}
|
||||
|
||||
Handle DetachWritableHandle() {
|
||||
return DetachWritableHandleOfSystemEvent(std::addressof(this->system_event));
|
||||
}
|
||||
|
||||
void Wait() {
|
||||
return WaitSystemEvent(std::addressof(this->system_event));
|
||||
}
|
||||
|
||||
bool TryWait() {
|
||||
return TryWaitSystemEvent(std::addressof(this->system_event));
|
||||
}
|
||||
|
||||
bool TimedWait(TimeSpan timeout) {
|
||||
return TimedWaitSystemEvent(std::addressof(this->system_event), timeout);
|
||||
}
|
||||
|
||||
void Signal() {
|
||||
return SignalSystemEvent(std::addressof(this->system_event));
|
||||
}
|
||||
|
||||
void Clear() {
|
||||
return ClearSystemEvent(std::addressof(this->system_event));
|
||||
}
|
||||
|
||||
Handle GetReadableHandle() const {
|
||||
return GetReadableHandleOfSystemEvent(std::addressof(this->system_event));
|
||||
}
|
||||
|
||||
Handle GetWritableHandle() const {
|
||||
return GetWritableHandleOfSystemEvent(std::addressof(this->system_event));
|
||||
}
|
||||
|
||||
operator SystemEventType &() {
|
||||
return this->system_event;
|
||||
}
|
||||
|
||||
operator const SystemEventType &() const {
|
||||
return this->system_event;
|
||||
}
|
||||
|
||||
SystemEventType *GetBase() {
|
||||
return std::addressof(this->system_event);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue