2018-05-04 05:58:25 +00:00
|
|
|
#pragma once
|
|
|
|
#include <switch.h>
|
|
|
|
#include <stratosphere.hpp>
|
|
|
|
|
2018-06-03 05:46:27 +00:00
|
|
|
class ProcessWaiter final : public IWaitable {
|
2018-05-04 05:58:25 +00:00
|
|
|
public:
|
|
|
|
Registration::Process process;
|
|
|
|
|
|
|
|
ProcessWaiter(Registration::Process p) : process(p) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ProcessWaiter(Registration::Process *p) {
|
|
|
|
this->process = *p;
|
|
|
|
}
|
|
|
|
|
|
|
|
Registration::Process *get_process() {
|
|
|
|
return &this->process;
|
|
|
|
}
|
|
|
|
|
2018-06-14 23:50:01 +00:00
|
|
|
/* IWaitable */
|
2018-06-03 05:46:27 +00:00
|
|
|
Handle get_handle() override {
|
2018-05-04 05:58:25 +00:00
|
|
|
return this->process.handle;
|
|
|
|
}
|
|
|
|
|
2018-06-03 05:46:27 +00:00
|
|
|
void handle_deferred() override {
|
2018-05-04 05:58:25 +00:00
|
|
|
/* TODO: Panic, because we can never be deferred. */
|
|
|
|
}
|
|
|
|
|
2018-06-03 05:46:27 +00:00
|
|
|
Result handle_signaled(u64 timeout) override {
|
2018-05-04 05:58:25 +00:00
|
|
|
Registration::HandleSignaledProcess(this->get_process());
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-06-03 05:46:27 +00:00
|
|
|
class ProcessList final : public IWaitable {
|
2018-05-04 05:58:25 +00:00
|
|
|
private:
|
|
|
|
HosRecursiveMutex mutex;
|
|
|
|
public:
|
|
|
|
std::vector<ProcessWaiter *> process_waiters;
|
|
|
|
|
|
|
|
void Lock() {
|
|
|
|
this->mutex.Lock();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Unlock() {
|
|
|
|
this->mutex.Unlock();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TryLock() {
|
|
|
|
return this->mutex.TryLock();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* IWaitable */
|
|
|
|
|
2018-06-03 05:46:27 +00:00
|
|
|
Handle get_handle() override {
|
2018-05-04 05:58:25 +00:00
|
|
|
/* TODO: Panic, because we don't have a handle. */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-06-03 05:46:27 +00:00
|
|
|
void handle_deferred() override {
|
2018-05-04 05:58:25 +00:00
|
|
|
/* TODO: Panic, because we can never be deferred. */
|
|
|
|
}
|
|
|
|
|
2018-06-03 05:46:27 +00:00
|
|
|
Result handle_signaled(u64 timeout) override {
|
2018-05-04 05:58:25 +00:00
|
|
|
/* TODO: Panic, because we can never be signaled. */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|