/*** Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved. File: AuGroupState.hpp Date: 2021-11-1 Author: Reece ***/ #pragma once #include "ThreadState.hpp" #include "AuGroupWorkQueue.hpp" namespace Aurora::Async { struct ThreadPool; struct GroupState : AuEnableSharedFromThis { // group id ThreadGroup_t group; // work items GroupWorkQueue workQueue; // tracked workers AuThreadPrimitives::Mutex workersMutex; AuFutexMutex deinitMutex; AuBST> workers; AuWPtr wpWorkers[32]; // linear non-locking lookup table // bool Init(); void SignalAll(bool bHasWork = true); void Decommit(ThreadId_t id); bool AddWorker(ThreadId_t id, AuSPtr pState); AuSPtr CreateWorker(WorkerId_t id, bool bCreate); AuSPtr GetThreadByIndex(ThreadId_t uIndex); }; }