From 2b777f1e38ebe8f618b5ca17f707e88661554541 Mon Sep 17 00:00:00 2001 From: Jamie Reece Wilson Date: Thu, 27 Jul 2023 16:31:47 +0100 Subject: [PATCH] [+] IIOProcessor::ConfigureNoDeferredTicks (hack for Qt modals) --- Include/Aurora/IO/IIOProcessor.hpp | 5 +++++ Source/IO/AuIOProcessor.cpp | 14 ++++++++++---- Source/IO/AuIOProcessor.hpp | 23 +++++++++++++---------- Source/IO/AuIOProcessorItem.cpp | 6 ++++-- 4 files changed, 32 insertions(+), 16 deletions(-) diff --git a/Include/Aurora/IO/IIOProcessor.hpp b/Include/Aurora/IO/IIOProcessor.hpp index 6e89005f..94e6470f 100644 --- a/Include/Aurora/IO/IIOProcessor.hpp +++ b/Include/Aurora/IO/IIOProcessor.hpp @@ -156,6 +156,11 @@ namespace Aurora::IO * @brief resets the io processors footprint in ::ToQueue() */ virtual void ReleaseAllWatches () = 0; + + /** + * @warning: do not use me. this is a niche hack for nested ui modal loops. + */ + virtual bool ConfigureNoDeferredTicks(bool bOption) = 0; }; /** diff --git a/Source/IO/AuIOProcessor.cpp b/Source/IO/AuIOProcessor.cpp index 21901196..14f937ff 100644 --- a/Source/IO/AuIOProcessor.cpp +++ b/Source/IO/AuIOProcessor.cpp @@ -134,7 +134,8 @@ namespace Aurora::IO return 0; } - if (this->bFrameStart) + if (this->bFrameStart && + !this->bNoDeferredTick) { return 0; } @@ -510,14 +511,14 @@ namespace Aurora::IO bool IOProcessor::AddEventListener(const AuSPtr &eventListener) { - AU_LOCK_GUARD(this->listenersSpinLock); + AU_LOCK_GUARD(this->listenersSpinLock->AsWritable()); return AuTryInsert(this->listeners, eventListener); } void IOProcessor::RemoveEventListener(const AuSPtr &eventListener) { - AU_LOCK_GUARD(this->listenersSpinLock); + AU_LOCK_GUARD(this->listenersSpinLock->AsWritable()); AuTryRemove(this->listeners, eventListener); } @@ -845,6 +846,11 @@ namespace Aurora::IO return this->pLoopQueue; } + bool IOProcessor::ConfigureNoDeferredTicks(bool bOption) + { + return AuExchange(this->bNoDeferredTick, bOption); + } + void IOProcessor::ReleaseAllWatches() { RemoveTimer(); @@ -874,7 +880,7 @@ namespace Aurora::IO void IOProcessor::ReportState(EIOProcessorEventStage stage) { - AU_LOCK_GUARD(this->listenersSpinLock); + AU_LOCK_GUARD(this->listenersSpinLock->AsReadable()); for (auto &listeners : this->listeners) { diff --git a/Source/IO/AuIOProcessor.hpp b/Source/IO/AuIOProcessor.hpp index 71d39eec..7f051bdd 100644 --- a/Source/IO/AuIOProcessor.hpp +++ b/Source/IO/AuIOProcessor.hpp @@ -31,7 +31,7 @@ namespace Aurora::IO bool TickForRegister(const AuSPtr &ioEvent); void TickForHack(const AuSPtr &ioEvent); - bool bScheduled_ {}; + AuUInt32 ManualTick() override; void DispatchFrame(ProcessInfo &info) override; @@ -80,6 +80,8 @@ namespace Aurora::IO AuSPtr ToQueue() override; void ReleaseAllWatches() override; + bool ConfigureNoDeferredTicks(bool bOption); + bool HasItems() override; void WakeupThread(); @@ -88,14 +90,6 @@ namespace Aurora::IO bool RequestRemovalForItemFromAnyThread(const AuSPtr &processor); - AuSPtr pLoopQueue; - - AuUInt threadId; - - AuUInt64 refreshRateNs {}; - AuUInt64 minFrameDeltaNs {}; - bool bIsNoQueue; - void UpdateTimers(); void AddTimer(); @@ -118,13 +112,22 @@ namespace Aurora::IO AuThreadPrimitives::MutexUnique_t mutex; - AuThreadPrimitives::SpinLock listenersSpinLock; + AuThreadPrimitives::RWLock listenersSpinLock; AuList> listeners; AuList> workUnits; IOPipeProcessor streamProcessors; + AuSPtr pLoopQueue; + + + AuUInt threadId {}; + AuUInt64 refreshRateNs {}; + AuUInt64 minFrameDeltaNs {}; + bool bIsNoQueue {}; bool bFrameStart {}; + bool bScheduled_ {}; + bool bNoDeferredTick {}; }; } \ No newline at end of file diff --git a/Source/IO/AuIOProcessorItem.cpp b/Source/IO/AuIOProcessorItem.cpp index cd4dc831..d1e612ea 100644 --- a/Source/IO/AuIOProcessorItem.cpp +++ b/Source/IO/AuIOProcessorItem.cpp @@ -67,9 +67,11 @@ namespace Aurora::IO { if (!this->pParent->IsTickOnly()) { - if (!this->pParent->bFrameStart) + bool bForceTick {}; + if (!this->pParent->bFrameStart || + (bForceTick = this->pParent->bNoDeferredTick)) { - if (force) + if (force || bForceTick) { this->pParent->TickFor(AuSharedFromThis()); }