/*** Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved. File: ThreadState.hpp Date: 2021-11-1 Author: Reece ***/ #pragma once #include "AsyncRunnable.hpp" namespace Aurora::Async { using WorkEntry_t = AuPair>; // TODO: this is a hack because i havent implemented an epoll abstraction yet struct AsyncAppWaitSourceRequest { AuConsumer, bool> callback; AuSPtr loopSource; AuUInt32 requestedOffset; AuUInt64 startTime; AuUInt64 endTime; }; struct GroupState; struct AsyncLoop; struct ThreadState { ThreadState() : running(true, false, true), cvVariable(AuUnsafeRaiiToShared(cvWorkMutex.AsPointer())), isDeadEvent(false, false, true) { } // :vomit: WorkerId_t id; AuUInt8 multipopCount = 32; AuUInt32 lastFrameTime {}; AuThreads::ThreadShared_t threadObject; AuWPtr parent; AuThreadPrimitives::Semaphore syncSema; AuThreadPrimitives::Event isDeadEvent; AuList> features; bool rejecting {}; bool exiting {}; bool shuttingdown {}; bool exitingflag2 {}; AuThreadPrimitives::Event running; //bool running; AuList loopSources; AuList pendingWorkItems; AuSPtr asyncLoop; Utility::RateLimiter rateLimiter; ERunMode runMode; int cookie {0}; bool bAlreadyDoingExitTick {}; bool bBreakEarly {}; bool bIsKiller {}; // AuThreadPrimitives::SpinLock externalFencesLock; AuList externalFences; // AuThreadPrimitives::ConditionMutex cvWorkMutex; AuThreadPrimitives::ConditionVariable cvVariable; AuAUInt32 cvSleepCount {}; AuAUInt32 cvLSActive {}; AuAUInt32 cvHasWork {}; AuSPtr eventLs; AuSPtr asyncLoopSourceShared; }; }