2017-05-31 09:45:12 -04:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
namespace Components
|
|
|
|
{
|
|
|
|
class Scheduler : public Component
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef void(Callback)();
|
|
|
|
|
|
|
|
Scheduler();
|
|
|
|
~Scheduler();
|
|
|
|
|
2017-07-03 09:07:47 -04:00
|
|
|
void preDestroy() override;
|
|
|
|
|
2017-05-31 09:45:12 -04:00
|
|
|
static void OnShutdown(Utils::Slot<Callback> callback);
|
2017-06-01 04:25:13 -04:00
|
|
|
static void OnFrame(Utils::Slot<Callback> callback, bool clientOnly = false);
|
|
|
|
static void OnReady(Utils::Slot<Callback> callback, bool clientOnly = false);
|
|
|
|
static void Once(Utils::Slot<Callback> callback, bool clientOnly = false);
|
|
|
|
static void OnDelay(Utils::Slot<Callback> callback, std::chrono::nanoseconds delay, bool clientOnly = false);
|
2017-05-31 09:45:12 -04:00
|
|
|
|
2017-07-03 09:07:47 -04:00
|
|
|
static void OnFrameAsync(Utils::Slot<Callback> callback);
|
|
|
|
static void OnceAsync(Utils::Slot<Callback> callback);
|
|
|
|
|
2017-05-31 09:45:12 -04:00
|
|
|
static void FrameHandler();
|
|
|
|
|
|
|
|
private:
|
|
|
|
class DelayedSlot
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
std::chrono::nanoseconds delay;
|
|
|
|
Utils::Time::Interval interval;
|
|
|
|
Utils::Slot<Callback> callback;
|
|
|
|
};
|
|
|
|
|
2017-07-03 09:07:47 -04:00
|
|
|
static bool AsyncTerminate;
|
|
|
|
static std::thread AsyncThread;
|
|
|
|
|
2017-05-31 09:45:12 -04:00
|
|
|
static Utils::Signal<Callback> FrameSignal;
|
|
|
|
static Utils::Signal<Callback> FrameOnceSignal;
|
|
|
|
static std::vector<DelayedSlot> DelayedSlots;
|
|
|
|
|
|
|
|
static bool ReadyPassed;
|
|
|
|
static Utils::Signal<Callback> ReadySignal;
|
|
|
|
static Utils::Signal<Callback> ShutdownSignal;
|
|
|
|
|
2017-07-03 09:07:47 -04:00
|
|
|
static Utils::Signal<Callback> AsyncFrameSignal;
|
|
|
|
static Utils::Signal<Callback> AsyncFrameOnceSignal;
|
|
|
|
|
2017-05-31 09:45:12 -04:00
|
|
|
static void ReadyHandler();
|
|
|
|
static void DelaySignal();
|
2017-05-31 10:09:41 -04:00
|
|
|
|
|
|
|
static void ShutdownStub(int num);
|
2017-05-31 09:45:12 -04:00
|
|
|
};
|
|
|
|
}
|