Jamie Reece Wilson
d803f1547c
[*] Move static functions out of the thread pool interface. no idea how i had successful builds before
72 lines
4.0 KiB
C++
72 lines
4.0 KiB
C++
/***
|
|
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
|
|
File: AsyncApp.hpp
|
|
Date: 2021-6-26
|
|
Author: Reece
|
|
***/
|
|
#pragma once
|
|
|
|
#include "ThreadPool.hpp"
|
|
|
|
namespace Aurora::Async
|
|
{
|
|
void InitApp();
|
|
void ReleaseApp();
|
|
|
|
inline struct AsyncApp *gAsyncApp;
|
|
|
|
struct AsyncApp : IAsyncApp, ThreadPool
|
|
{
|
|
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) override;
|
|
AuSPtr<IWorkItem> NewWorkFunction(const WorkerId_t &worker, AuVoidFunc callback) 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 Wakeup(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<AuIO::IIOProcessor> GetIOProcessor(WorkerId_t pid) override;
|
|
AuSPtr<AuIO::Net::INetInterface> GetIONetInterface(WorkerId_t pid) override;
|
|
AuSPtr<AuIO::Net::INetWorker> GetIONetWorker(WorkerId_t pid) override;
|
|
AuSPtr<AuLoop::ILoopQueue> ToKernelWorkQueue() override;
|
|
AuSPtr<AuLoop::ILoopQueue> ToKernelWorkQueue(WorkerId_t workerId) override;
|
|
AuSPtr<IO::CompletionGroup::ICompletionGroup> GetIOGroup(WorkerId_t id) override;
|
|
|
|
// Main thread logic
|
|
void Start() override;
|
|
void Main() override;
|
|
void SetConsoleCommandDispatcher(WorkerId_t id) override;
|
|
|
|
AuSPtr<Aurora::Threading::IWaitable> GetShutdownEvent() override;
|
|
void AddDependency(AuSPtr<IThreadPool> pPool) override;
|
|
|
|
void IncrementAbortFenceOnPool() override;
|
|
void IncrementAbortFenceOnWorker(WorkerId_t workerId) override;
|
|
|
|
AuUInt64 QueryAbortFence(AuOptional<WorkerId_t> optWorkerId) override;
|
|
bool QueryShouldAbort(AuOptional<WorkerId_t> optWorkerId, AuUInt64 uFenceMagic) override;
|
|
|
|
void CleanUpWorker(WorkerId_t wid) override;
|
|
void CleanWorkerPoolReservedZeroFree() override;
|
|
|
|
AuOptional<WorkerId_t> commandDispatcher_;
|
|
};
|
|
} |