mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-05-31 23:08:22 -04:00
os: implement waitable management.
This implements waitable management for Events (and implements Events). It also refactors PM to use new Event/Waitable semantics, and also adds STS_ASSERT as a macro for asserting a boolean expression. The rest of stratosphere has been refactored to use STS_ASSERT whenever possible.
This commit is contained in:
parent
e07011be32
commit
609a302e16
108 changed files with 2752 additions and 1223 deletions
|
@ -24,20 +24,29 @@ namespace sts::fatal::srv {
|
|||
FatalConfig g_config;
|
||||
|
||||
/* Event creator. */
|
||||
IEvent *CreateFatalDirtyEvent() {
|
||||
Handle GetFatalDirtyEventReadableHandle() {
|
||||
Event evt;
|
||||
R_ASSERT(setsysBindFatalDirtyFlagEvent(&evt));
|
||||
return LoadReadOnlySystemEvent(evt.revent, [](u64 timeout) {
|
||||
u64 flags_0, flags_1;
|
||||
if (R_SUCCEEDED(setsysGetFatalDirtyFlags(&flags_0, &flags_1)) && (flags_0 & 1)) {
|
||||
g_config.UpdateLanguageCode();
|
||||
}
|
||||
return ResultSuccess;
|
||||
}, true);
|
||||
return evt.revent;
|
||||
}
|
||||
|
||||
/* Global event. */
|
||||
IEvent *g_fatal_dirty_event = CreateFatalDirtyEvent();
|
||||
os::SystemEvent g_fatal_dirty_event(GetFatalDirtyEventReadableHandle(), true, false);
|
||||
os::WaitableHolder g_fatal_dirty_waitable_holder(&g_fatal_dirty_event);
|
||||
|
||||
}
|
||||
|
||||
os::WaitableHolder *GetFatalDirtyWaitableHolder() {
|
||||
return &g_fatal_dirty_waitable_holder;
|
||||
}
|
||||
|
||||
void OnFatalDirtyEvent() {
|
||||
g_fatal_dirty_event.Reset();
|
||||
|
||||
u64 flags_0, flags_1;
|
||||
if (R_SUCCEEDED(setsysGetFatalDirtyFlags(&flags_0, &flags_1)) && (flags_0 & 1)) {
|
||||
g_config.UpdateLanguageCode();
|
||||
}
|
||||
}
|
||||
|
||||
FatalConfig::FatalConfig() {
|
||||
|
@ -84,10 +93,6 @@ namespace sts::fatal::srv {
|
|||
}
|
||||
}
|
||||
|
||||
IEvent *GetFatalDirtyEvent() {
|
||||
return g_fatal_dirty_event;
|
||||
}
|
||||
|
||||
const FatalConfig &GetFatalConfig() {
|
||||
return g_config;
|
||||
}
|
||||
|
|
|
@ -90,7 +90,8 @@ namespace sts::fatal::srv {
|
|||
}
|
||||
};
|
||||
|
||||
IEvent *GetFatalDirtyEvent();
|
||||
os::WaitableHolder *GetFatalDirtyWaitableHolder();
|
||||
void OnFatalDirtyEvent();
|
||||
const FatalConfig &GetFatalConfig();
|
||||
|
||||
}
|
||||
|
|
|
@ -156,7 +156,7 @@ namespace sts::fatal::srv {
|
|||
|
||||
void TryCollectDebugInformation(ThrowContext *ctx, u64 process_id) {
|
||||
/* Try to debug the process. This may fail, if we called into ourself. */
|
||||
AutoHandle debug_handle;
|
||||
os::ManagedHandle debug_handle;
|
||||
if (R_FAILED(svcDebugActiveProcess(debug_handle.GetPointer(), process_id))) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -133,7 +133,9 @@ int main(int argc, char **argv)
|
|||
/* Create services. */
|
||||
s_server_manager.AddWaitable(new ServiceServer<sts::fatal::srv::PrivateService>("fatal:p", 4));
|
||||
s_server_manager.AddWaitable(new ServiceServer<sts::fatal::srv::UserService>("fatal:u", 4));
|
||||
s_server_manager.AddWaitable(sts::fatal::srv::GetFatalDirtyEvent());
|
||||
/* TODO: s_server_manager.AddWaitable(sts::fatal::srv::GetFatalDirtyEvent()); */
|
||||
auto dirty_event_holder = sts::fatal::srv::GetFatalDirtyWaitableHolder();
|
||||
(void)dirty_event_holder;
|
||||
|
||||
/* Loop forever, servicing our services. */
|
||||
s_server_manager.Process();
|
||||
|
|
|
@ -60,10 +60,7 @@ namespace sts::fatal::srv {
|
|||
public:
|
||||
TaskManager() { /* ... */ }
|
||||
void StartTask(ITask *task) {
|
||||
if (this->task_count >= MaxTasks) {
|
||||
std::abort();
|
||||
}
|
||||
|
||||
STS_ASSERT(this->task_count < MaxTasks);
|
||||
this->task_threads[this->task_count++].StartTask(task);
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue