[+] IIOProcessor::ConfigureNoDeferredTicks (hack for Qt modals)

This commit is contained in:
Reece Wilson 2023-07-27 16:31:47 +01:00
parent b411c710d1
commit 2b777f1e38
4 changed files with 32 additions and 16 deletions

View File

@ -156,6 +156,11 @@ namespace Aurora::IO
* @brief resets the io processors footprint in ::ToQueue() * @brief resets the io processors footprint in ::ToQueue()
*/ */
virtual void ReleaseAllWatches () = 0; 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;
}; };
/** /**

View File

@ -134,7 +134,8 @@ namespace Aurora::IO
return 0; return 0;
} }
if (this->bFrameStart) if (this->bFrameStart &&
!this->bNoDeferredTick)
{ {
return 0; return 0;
} }
@ -510,14 +511,14 @@ namespace Aurora::IO
bool IOProcessor::AddEventListener(const AuSPtr<IIOProcessorEventListener> &eventListener) bool IOProcessor::AddEventListener(const AuSPtr<IIOProcessorEventListener> &eventListener)
{ {
AU_LOCK_GUARD(this->listenersSpinLock); AU_LOCK_GUARD(this->listenersSpinLock->AsWritable());
return AuTryInsert(this->listeners, eventListener); return AuTryInsert(this->listeners, eventListener);
} }
void IOProcessor::RemoveEventListener(const AuSPtr<IIOProcessorEventListener> &eventListener) void IOProcessor::RemoveEventListener(const AuSPtr<IIOProcessorEventListener> &eventListener)
{ {
AU_LOCK_GUARD(this->listenersSpinLock); AU_LOCK_GUARD(this->listenersSpinLock->AsWritable());
AuTryRemove(this->listeners, eventListener); AuTryRemove(this->listeners, eventListener);
} }
@ -845,6 +846,11 @@ namespace Aurora::IO
return this->pLoopQueue; return this->pLoopQueue;
} }
bool IOProcessor::ConfigureNoDeferredTicks(bool bOption)
{
return AuExchange(this->bNoDeferredTick, bOption);
}
void IOProcessor::ReleaseAllWatches() void IOProcessor::ReleaseAllWatches()
{ {
RemoveTimer(); RemoveTimer();
@ -874,7 +880,7 @@ namespace Aurora::IO
void IOProcessor::ReportState(EIOProcessorEventStage stage) void IOProcessor::ReportState(EIOProcessorEventStage stage)
{ {
AU_LOCK_GUARD(this->listenersSpinLock); AU_LOCK_GUARD(this->listenersSpinLock->AsReadable());
for (auto &listeners : this->listeners) for (auto &listeners : this->listeners)
{ {

View File

@ -31,7 +31,7 @@ namespace Aurora::IO
bool TickForRegister(const AuSPtr<IIOProcessorItem> &ioEvent); bool TickForRegister(const AuSPtr<IIOProcessorItem> &ioEvent);
void TickForHack(const AuSPtr<IIOProcessorItem> &ioEvent); void TickForHack(const AuSPtr<IIOProcessorItem> &ioEvent);
bool bScheduled_ {};
AuUInt32 ManualTick() override; AuUInt32 ManualTick() override;
void DispatchFrame(ProcessInfo &info) override; void DispatchFrame(ProcessInfo &info) override;
@ -80,6 +80,8 @@ namespace Aurora::IO
AuSPtr<AuLoop::ILoopQueue> ToQueue() override; AuSPtr<AuLoop::ILoopQueue> ToQueue() override;
void ReleaseAllWatches() override; void ReleaseAllWatches() override;
bool ConfigureNoDeferredTicks(bool bOption);
bool HasItems() override; bool HasItems() override;
void WakeupThread(); void WakeupThread();
@ -88,14 +90,6 @@ namespace Aurora::IO
bool RequestRemovalForItemFromAnyThread(const AuSPtr<IIOProcessorItem> &processor); bool RequestRemovalForItemFromAnyThread(const AuSPtr<IIOProcessorItem> &processor);
AuSPtr<AuLoop::ILoopQueue> pLoopQueue;
AuUInt threadId;
AuUInt64 refreshRateNs {};
AuUInt64 minFrameDeltaNs {};
bool bIsNoQueue;
void UpdateTimers(); void UpdateTimers();
void AddTimer(); void AddTimer();
@ -118,13 +112,22 @@ namespace Aurora::IO
AuThreadPrimitives::MutexUnique_t mutex; AuThreadPrimitives::MutexUnique_t mutex;
AuThreadPrimitives::SpinLock listenersSpinLock; AuThreadPrimitives::RWLock listenersSpinLock;
AuList<AuSPtr<IIOProcessorEventListener>> listeners; AuList<AuSPtr<IIOProcessorEventListener>> listeners;
AuList<AuSPtr<IIOProcessorWorkUnit>> workUnits; AuList<AuSPtr<IIOProcessorWorkUnit>> workUnits;
IOPipeProcessor streamProcessors; IOPipeProcessor streamProcessors;
AuSPtr<AuLoop::ILoopQueue> pLoopQueue;
AuUInt threadId {};
AuUInt64 refreshRateNs {};
AuUInt64 minFrameDeltaNs {};
bool bIsNoQueue {};
bool bFrameStart {}; bool bFrameStart {};
bool bScheduled_ {};
bool bNoDeferredTick {};
}; };
} }

View File

@ -67,9 +67,11 @@ namespace Aurora::IO
{ {
if (!this->pParent->IsTickOnly()) 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()); this->pParent->TickFor(AuSharedFromThis());
} }