mirror of
https://github.com/Atmosphere-NX/Atmosphere-libs.git
synced 2025-06-21 11:02:45 +02:00
ProcessManager: Fill out ProcessTracking::Initialize()
This commit is contained in:
parent
90c7f03a9d
commit
af6d60d06c
@ -7,6 +7,10 @@
|
||||
#include "stratosphere/serviceserver.hpp"
|
||||
#include "stratosphere/managedportserver.hpp"
|
||||
#include "stratosphere/existingportserver.hpp"
|
||||
|
||||
#include "stratosphere/ievent.hpp"
|
||||
#include "stratosphere/systemevent.hpp"
|
||||
|
||||
#include "stratosphere/waitablemanager.hpp"
|
||||
|
||||
#include "stratosphere/ipc_templating.hpp"
|
68
include/stratosphere/ievent.hpp
Normal file
68
include/stratosphere/ievent.hpp
Normal file
@ -0,0 +1,68 @@
|
||||
#pragma once
|
||||
#include <switch.h>
|
||||
#include <vector>
|
||||
|
||||
#include "iwaitable.hpp"
|
||||
|
||||
typedef Result (*EventCallback)(Handle *handles, size_t num_handles, u64 timeout);
|
||||
|
||||
class IEvent : IWaitable {
|
||||
protected:
|
||||
std::vector<Handle> handles;
|
||||
EventCallback callback;
|
||||
|
||||
public:
|
||||
IEvent(Handle wait_h, EventCallback callback) {
|
||||
if (wait_h) {
|
||||
this->handles.push_back(wait_h);
|
||||
}
|
||||
this->callback = callback;
|
||||
}
|
||||
|
||||
~IEvent() {
|
||||
for (auto &h : this->handles) {
|
||||
svcCloseHandle(h);
|
||||
}
|
||||
}
|
||||
|
||||
virtual Result signal_event() = 0;
|
||||
|
||||
/* IWaitable */
|
||||
virtual unsigned int get_num_waitables() {
|
||||
if (handles.size() > 0) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual void get_waitables(IWaitable **dst) {
|
||||
if (handles.size() > 0) {
|
||||
dst[0] = this;
|
||||
}
|
||||
}
|
||||
|
||||
virtual void delete_child(IWaitable *child) {
|
||||
/* TODO: Panic, an event can never be a parent. */
|
||||
}
|
||||
|
||||
virtual Handle get_handle() {
|
||||
if (handles.size() > 0) {
|
||||
return this->handles[0];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
virtual void handle_deferred() {
|
||||
/* TODO: Panic, because we can never defer an event. */
|
||||
}
|
||||
|
||||
virtual Result handle_signaled(u64 timeout) {
|
||||
return this->callback(this->handles.data(), this->handles.size(), timeout);
|
||||
}
|
||||
|
||||
static Result PanicCallback(Handle *handles, size_t num_handles, u64 timeout) {
|
||||
/* TODO: Panic. */
|
||||
return 0xCAFE;
|
||||
}
|
||||
};
|
26
include/stratosphere/systemevent.hpp
Normal file
26
include/stratosphere/systemevent.hpp
Normal file
@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
#include <switch.h>
|
||||
|
||||
#include "iwaitable.hpp"
|
||||
#include "ievent.hpp"
|
||||
|
||||
#define SYSTEMEVENT_INDEX_WAITHANDLE 0
|
||||
#define SYSTEMEVENT_INDEX_SGNLHANDLE 1
|
||||
|
||||
class SystemEvent : IEvent {
|
||||
public:
|
||||
SystemEvent(EventCallback callback) : IEvent(0, callback) {
|
||||
Handle wait_h;
|
||||
Handle sig_h;
|
||||
if (R_FAILED(svcCreateEvent(&wait_h, &sig_h))) {
|
||||
/* TODO: Panic. */
|
||||
}
|
||||
|
||||
this->handles.push_back(wait_h);
|
||||
this->handles.push_back(sig_h);
|
||||
}
|
||||
|
||||
virtual Result signal_event() {
|
||||
return svcSignalEvent(this->handles[SYSTEMEVENT_INDEX_SGNLHANDLE]);
|
||||
}
|
||||
};
|
Loading…
Reference in New Issue
Block a user