2018-04-18 18:41:17 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <switch.h>
|
|
|
|
|
|
|
|
class IWaitable {
|
|
|
|
u64 wait_priority = 0;
|
|
|
|
IWaitable *parent_waitable;
|
|
|
|
public:
|
2018-04-18 19:10:45 +01:00
|
|
|
virtual ~IWaitable() { }
|
|
|
|
|
2018-04-18 18:41:17 +01:00
|
|
|
virtual unsigned int get_num_waitables() = 0;
|
|
|
|
virtual void get_waitables(IWaitable **dst) = 0;
|
|
|
|
virtual void delete_child(IWaitable *child) = 0;
|
|
|
|
virtual Handle get_handle() = 0;
|
2018-04-18 19:53:04 +01:00
|
|
|
virtual Result handle_signaled(u64 timeout) = 0;
|
2018-04-18 18:41:17 +01:00
|
|
|
|
|
|
|
bool has_parent() {
|
|
|
|
return this->parent_waitable != NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
IWaitable *get_parent() {
|
|
|
|
return this->parent_waitable;
|
|
|
|
}
|
|
|
|
|
|
|
|
void update_priority() {
|
|
|
|
static u64 g_cur_priority = 0;
|
|
|
|
this->wait_priority = g_cur_priority++;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool compare(IWaitable *a, IWaitable *b) {
|
|
|
|
return (a->wait_priority < b->wait_priority);
|
|
|
|
}
|
|
|
|
};
|