AuroraRuntime/Source/Async/AsyncApp.hpp

63 lines
3.4 KiB
C++
Raw Normal View History

/***
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: AsyncApp.hpp
Date: 2021-6-26
Author: Reece
***/
2021-06-27 21:25:29 +00:00
#pragma once
#include "ThreadPool.hpp"
2021-06-27 21:25:29 +00:00
namespace Aurora::Async
{
void InitApp();
void ReleaseApp();
inline struct AsyncApp *gAsyncApp;
2021-06-30 12:00:32 +00:00
struct AsyncApp : IAsyncApp, ThreadPool
2021-06-30 09:28:52 +00:00
{
bool Spawn(WorkerId_t workerId) override;
void SetRunningMode(bool eventRunning) override;
bool Create(WorkerId_t workerId) override;
bool InRunnerMode() override;
bool Poll() override;
bool RunOnce() override;
bool Run() override;
void Shutdown() override;
bool Exiting() override;
AuUInt32 PollAndCount(bool bStrict = true) override;
AuUInt32 RunAllPending() override;
AuSPtr<IWorkItem> NewWorkItem(const WorkerId_t &worker, const AuSPtr<IWorkItemHandler> &task, bool supportsBlocking) override;
AuSPtr<IWorkItem> NewFence() override;
Threading::Threads::ThreadShared_t ResolveHandle(WorkerId_t) override;
AuBST<ThreadGroup_t, AuList<ThreadId_t>> GetThreads() override;
WorkerId_t GetCurrentThread() override;
bool Sync(WorkerId_t workerId, AuUInt32 timeoutMs = 0, bool requireSignal = false) override;
AuSPtr<AuLoop::ILoopSource> WorkerToLoopSource(WorkerId_t id) override;
void Signal(WorkerId_t workerId) override;
void SyncAllSafe() override;
void AddFeature(WorkerId_t id, AuSPtr<Threading::Threads::IThreadFeature> feature, bool async) override;
void AssertInThreadGroup(ThreadGroup_t group) override;
void AssertWorker(WorkerId_t id) override;
AuSPtr<AuLoop::ILoopQueue> ToKernelWorkQueue() override;
AuSPtr<AuLoop::ILoopQueue> ToKernelWorkQueue(WorkerId_t workerId) override;
2022-03-10 15:35:01 +00:00
void UpdateWorkMode(WorkerId_t workerId, RunMode mode) override;
ERunMode GetCurrentThreadRunMode() override;
ERunMode GetThreadRunMode(WorkerId_t workerId) override;
2021-06-30 09:28:52 +00:00
// Main thread logic
void Start() override;
void Main() override;
void SetConsoleCommandDispatcher(WorkerId_t id) override;
2021-06-30 09:28:52 +00:00
AuSPtr<Aurora::Threading::IWaitable> GetShutdownEvent() override;
void CleanUpWorker(WorkerId_t wid) override;
void CleanWorkerPoolReservedZeroFree() override;
2021-06-30 09:28:52 +00:00
2021-09-06 10:58:08 +00:00
AuOptional<WorkerId_t> commandDispatcher_;
2021-06-30 09:28:52 +00:00
};
2021-06-27 21:25:29 +00:00
}