AuroraRuntime/Source/Async/GroupState.hpp
Reece 6af9940bd4 [*] Rewrite a bit of AuAsync
(maybe 1/3 of a rewrite)
2023-05-25 01:55:55 +01:00

50 lines
1.1 KiB
C++

/***
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: GroupState.hpp
Date: 2021-11-1
Author: Reece
***/
#pragma once
#include "ThreadState.hpp"
namespace Aurora::Async
{
struct GroupWorkQueue
{
AuThreadPrimitives::Mutex mutex;
AuUInt32 uItems {};
AuList<WorkEntry_t> sortedWork[AuAsync::kEWorkPrioCount];
bool IsEmpty();
bool IsEmpty(AuWorkerId_t id);
void AddWorkEntry(WorkEntry_t entry);
void Dequeue(AuList<WorkEntry_t> &queue, int maxPopCount, AuAsync::ThreadId_t idd);
};
struct GroupState
{
ThreadGroup_t group;
GroupWorkQueue workQueue;
AuThreadPrimitives::Mutex workersMutex;
AuBST<ThreadId_t, AuSPtr<ThreadState>> workers;
AuWPtr<ThreadState> wpWorkers[32];
bool Init();
void BroadCast();
void AddWorker(ThreadId_t id, AuSPtr<ThreadState> pState);
AuSPtr<ThreadState> GetThreadByIndex(ThreadId_t uIndex);
bool inline IsSysThread()
{
return group == 0;
}
};
}