From d0fb19f87e15490c35953085a60c7940a9a750e1 Mon Sep 17 00:00:00 2001 From: Jamie Reece Wilson Date: Fri, 15 Sep 2023 18:08:02 +0100 Subject: [PATCH] [*] Global build regressions caused by addd4080 --- Source/Async/Schedular.cpp | 9 ++++----- Source/Async/WorkItem.cpp | 10 +++++----- Source/Console/Commands/Commands.cpp | 20 ++++++++++---------- Source/Console/Commands/Commands.hpp | 2 +- Source/IO/AuIOProcessor.cpp | 18 +++++++++--------- Source/IO/AuIOProcessor.hpp | 2 +- Source/IO/Net/AuNetWorker.hpp | 2 +- 7 files changed, 31 insertions(+), 32 deletions(-) diff --git a/Source/Async/Schedular.cpp b/Source/Async/Schedular.cpp index db805a49..207bdf29 100644 --- a/Source/Async/Schedular.cpp +++ b/Source/Async/Schedular.cpp @@ -36,7 +36,7 @@ namespace Aurora::Async // old sewage to be cleaned up static bool gBOriginal; - static AuWorkerPId_t gMainThread; + static AuOptionalEx gMainThread; void StartSched2(); static void SchedNextTime(AuUInt64 uNSAbs); @@ -171,7 +171,7 @@ namespace Aurora::Async { if (!AuExchange(gLockedPump, true)) { - NewWorkItem(gMainThread, AuMakeShared(PumpSysThread))->Dispatch(); + NewWorkItem(gMainThread.value(), AuMakeShared(PumpSysThread))->Dispatch(); } SchedNextTime(AuMSToNS(gRuntimeConfig.async.dwLegacyMainThreadSystemTickMS) + AuTime::SteadyClockNS()); @@ -197,12 +197,11 @@ namespace Aurora::Async AUKN_SYM void SetMainThreadForSysPumpScheduling(AuWorkerPId_t pid) { - if (!pid) + if (!pid.pool) { gRuntimeConfig.async.bEnableLegacyTicks = gBOriginal; - gMainThread = AuWorkerPId_t(AuAsync::GetSharedAsyncApp(), AuWorkerId_t {0, 0}); + AuResetMember(gMainThread); Console::Commands::UpdateDispatcher(gMainThread); - return; } diff --git a/Source/Async/WorkItem.cpp b/Source/Async/WorkItem.cpp index ae6c8eec..72c3fc49 100644 --- a/Source/Async/WorkItem.cpp +++ b/Source/Async/WorkItem.cpp @@ -480,7 +480,7 @@ namespace Aurora::Async auto pWorker = GetCurrentWorkerPId().pool; if (!pWorker) { - pWorker = AuUnsafeRaiiToShared(gAsyncApp); + pWorker = AuUnsafeRaiiToShared(static_cast(gAsyncApp)); } return AuMakeShared(ToInternal(pWorker).get(), WorkerPId_t { pWorker , worker }, task); @@ -504,7 +504,7 @@ namespace Aurora::Async if (!pWorker) { - pWorker = AuUnsafeRaiiToShared(gAsyncApp); + pWorker = AuUnsafeRaiiToShared(static_cast(gAsyncApp)); } return AuMakeSharedThrow(ToInternal(pWorker).get(), worker, AuMove(func)); @@ -528,7 +528,7 @@ namespace Aurora::Async if (!pWorker) { - pWorker = AuUnsafeRaiiToShared(gAsyncApp); + pWorker = AuUnsafeRaiiToShared(static_cast(gAsyncApp)); } return AuMakeSharedThrow(ToInternal(pWorker).get(), worker, task); @@ -539,7 +539,7 @@ namespace Aurora::Async auto pWorker = GetCurrentWorkerPId().pool; if (!pWorker) { - pWorker = AuUnsafeRaiiToShared(gAsyncApp); + pWorker = AuUnsafeRaiiToShared(static_cast(gAsyncApp)); } return AuMakeShared((IThreadPoolInternal *)ToInternal(pWorker).get(), WorkerPId_t {}, AuSPtr{}); } @@ -560,7 +560,7 @@ namespace Aurora::Async { return nullptr; } - + auto priv = reinterpret_cast(this->task_->GetPrivateData()); if (!priv) { diff --git a/Source/Console/Commands/Commands.cpp b/Source/Console/Commands/Commands.cpp index 7b07b8c9..cf8edbac 100644 --- a/Source/Console/Commands/Commands.cpp +++ b/Source/Console/Commands/Commands.cpp @@ -23,10 +23,10 @@ namespace Aurora::Console::Commands static AuHashMap gCommands; static AuList gLineCallbacks; static AuList gPendingCommands; - static AuThreadPrimitives::Mutex gMutex; - static AuThreadPrimitives::Mutex gPendingCommandsMutex; - static Async::WorkerPId_t gCommandDispatcher; - + static AuMutex gMutex; + static AuMutex gPendingCommandsMutex; + static AuOptionalEx gCommandDispatcher; + struct Command { AuString tag; @@ -44,7 +44,7 @@ namespace Aurora::Console::Commands eAsync }; - static bool Dispatch(const AuString &string, EDispatchType type, Async::WorkerPId_t workerId) + static bool Dispatch(const AuString &string, EDispatchType type, AuOptionalEx workerId) { Parse::ParseResult res; AuSPtr callback; @@ -102,9 +102,9 @@ namespace Aurora::Console::Commands { callback->OnCommand(res.result); } - else + else if (workerId) { - Async::NewWorkFunction(workerId, [=]() -> void + Async::NewWorkFunction(workerId.value(), [=]() -> void { callback->OnCommand(res.result); }); @@ -146,7 +146,7 @@ namespace Aurora::Console::Commands return Dispatch(string, EDispatchType::eAsync, id); } - void UpdateDispatcher(AuOptional target) + void UpdateDispatcher(AuOptionalEx target) { AU_LOCK_GUARD(gMutex); AU_LOCK_GUARD(gPendingCommandsMutex); @@ -161,7 +161,7 @@ namespace Aurora::Console::Commands } } - gCommandDispatcher = target.value(); + gCommandDispatcher = target; } static void DispatchCommandsFromThis(const AuList &commands) @@ -180,7 +180,7 @@ namespace Aurora::Console::Commands } else { - NewWorkItem(gCommandDispatcher, AuMakeShared(func))->Dispatch()->BlockUntilComplete(); + NewWorkItem(gCommandDispatcher.value(), AuMakeShared(func))->Dispatch()->BlockUntilComplete(); } } diff --git a/Source/Console/Commands/Commands.hpp b/Source/Console/Commands/Commands.hpp index 8b3731b0..04d3cea2 100644 --- a/Source/Console/Commands/Commands.hpp +++ b/Source/Console/Commands/Commands.hpp @@ -9,7 +9,7 @@ namespace Aurora::Console::Commands { - void UpdateDispatcher(AuOptional target); + void UpdateDispatcher(AuOptionalEx target); void PumpCommands(); void RunCommandFunction(const AuFunction &func); } \ No newline at end of file diff --git a/Source/IO/AuIOProcessor.cpp b/Source/IO/AuIOProcessor.cpp index 621cfb84..53597d07 100644 --- a/Source/IO/AuIOProcessor.cpp +++ b/Source/IO/AuIOProcessor.cpp @@ -75,7 +75,7 @@ namespace Aurora::IO if (asyncWorker) { - AuAtomicAdd(&AuStaticCast(asyncWorker.pool)->uAtomicIOProcessors, 1u); + AuAtomicAdd(&AuStaticCast(asyncWorker.value().pool)->uAtomicIOProcessors, 1u); } return true; @@ -633,9 +633,9 @@ namespace Aurora::IO void IOProcessor::AddTimerLS() { - if (asyncWorker) + if (auto optWorker = this->asyncWorker) { - AuAtomicAdd(&AuStaticCast(asyncWorker.pool)->uAtomicIOProcessorsWorthlessSources, 1u); + AuAtomicAdd(&AuStaticCast(optWorker.value().pool)->uAtomicIOProcessorsWorthlessSources, 1u); } this->ToQueue()->SourceAdd(this->timers.pLsTicker); @@ -647,7 +647,7 @@ namespace Aurora::IO { if (!this->pWorkItem) { - this->pWorkItem = this->asyncWorker.pool->NewWorkItem(this->asyncWorker, AuSharedFromThis()); + this->pWorkItem = this->asyncWorker.value().pool->NewWorkItem(this->asyncWorker.value(), AuSharedFromThis()); } this->pWorkItem->SetSchedTimeNs(this->refreshRateNs); @@ -688,15 +688,15 @@ namespace Aurora::IO queue->SourceRemove(this->timers.pLsTicker); - if (asyncWorker) + if (auto optWorker = this->asyncWorker) { - AuAtomicSub(&AuStaticCast(asyncWorker.pool)->uAtomicIOProcessorsWorthlessSources, 1u); + AuAtomicSub(&AuStaticCast(optWorker.value().pool)->uAtomicIOProcessorsWorthlessSources, 1u); } } bool IOProcessor::IsAsync() { - return bool(this->asyncWorker.pool); + return bool(this->asyncWorker); } bool IOProcessor::IsTickOnly() @@ -869,9 +869,9 @@ namespace Aurora::IO void IOProcessor::ReleaseAllWatches() { - if (asyncWorker) + if (auto optWorker = this->asyncWorker) { - AuAtomicSub(&AuStaticCast(asyncWorker.pool)->uAtomicIOProcessors, 1u); + AuAtomicSub(&AuStaticCast(optWorker.value().pool)->uAtomicIOProcessors, 1u); } RemoveTimer(); diff --git a/Source/IO/AuIOProcessor.hpp b/Source/IO/AuIOProcessor.hpp index 9f4019fe..4848033f 100644 --- a/Source/IO/AuIOProcessor.hpp +++ b/Source/IO/AuIOProcessor.hpp @@ -107,7 +107,7 @@ namespace Aurora::IO IOProcessorItems items; IOProcessorTimers timers; - AuAsync::WorkerPId_t asyncWorker; + AuOptionalEx asyncWorker; AuSPtr pWorkItem; AuThreadPrimitives::MutexUnique_t mutex; diff --git a/Source/IO/Net/AuNetWorker.hpp b/Source/IO/Net/AuNetWorker.hpp index f743420c..2301f097 100644 --- a/Source/IO/Net/AuNetWorker.hpp +++ b/Source/IO/Net/AuNetWorker.hpp @@ -105,7 +105,7 @@ namespace Aurora::IO::Net AuSPtr temp; auto pid = AuAsync::GetCurrentWorkerPId(); - if (pid) + if (pid.pool) { temp = AuMakeShared(work, callback, pid); }