80 lines
1.9 KiB
C++
80 lines
1.9 KiB
C++
/***
|
|
Copyright (C) 2023 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
|
|
File: AuThreadState.hpp
|
|
Date: 2023-11-04
|
|
Author: Reece
|
|
***/
|
|
#pragma once
|
|
|
|
#include "AuThreadStateSingletons.hpp"
|
|
|
|
namespace Aurora::Async
|
|
{
|
|
struct AsyncLoop;
|
|
struct GroupState;
|
|
struct ThreadState;
|
|
|
|
struct ThreadStateShutdown
|
|
{
|
|
bool bBreakMainLoop {};
|
|
bool bDropSubmissions {};
|
|
bool bIsKillerThread {};
|
|
AuUInt32 uShutdownFence { 1 };
|
|
};
|
|
|
|
struct ThreadStateSync
|
|
{
|
|
ThreadStateSync();
|
|
|
|
AuConditionMutex cvWorkMutex;
|
|
AuConditionVariable cvVariable;
|
|
AuAUInt32 cvLSActive {};
|
|
AuAUInt32 cvHasWork {};
|
|
AuSPtr<AuLoop::ILSEvent> eventLs;
|
|
|
|
void SetEvent(bool bBoth = true, bool bHasWork = false);
|
|
bool Init();
|
|
void UpdateCVState(ThreadState *pState);
|
|
};
|
|
|
|
struct ThreadStateMeta
|
|
{
|
|
bool bOwnsThread {};
|
|
AuThreads::ThreadShared_t pThread;
|
|
WorkerId_t id;
|
|
};
|
|
|
|
struct ThreadStateStack
|
|
{
|
|
AuUInt32 uStackCookie {};
|
|
AuUInt32 uStackMaxRecursiveAsyncPromiseCalls { 4 };
|
|
AuUInt32 uStackCallDepth {};
|
|
AuUInt32 uStackMaxCookie { 5 };
|
|
AuUInt8 uWorkMultipopCount { 32 };
|
|
};
|
|
|
|
struct ThreadStateFeatureCallbacks
|
|
{
|
|
AuMutex mutex;
|
|
AuList<AuSPtr<AuThreads::IThreadFeature>> features;
|
|
};
|
|
|
|
struct ThreadStateBase
|
|
{
|
|
ThreadStateBase();
|
|
~ThreadStateBase();
|
|
|
|
AuWPtr<GroupState> parent;
|
|
/////////////////////////////////
|
|
ThreadStateShutdown shutdown;
|
|
ThreadStateMeta thread;
|
|
ThreadStateSync sync;
|
|
AuSPtr<AsyncLoop> asyncLoop;
|
|
ThreadStateStack stackState;
|
|
ThreadStateFeatureCallbacks tlsFeatures;
|
|
ThreadStateSingletons singletons;
|
|
|
|
bool Init();
|
|
};
|
|
} |