[*] More NT Loop Queue fixes

This commit is contained in:
Reece Wilson 2023-10-21 14:19:12 +01:00
parent 5233dc7ac8
commit f9916e0f21
2 changed files with 41 additions and 10 deletions

View File

@ -97,6 +97,8 @@ namespace Aurora::IO::Loop
try
{
AU_DEBUG_REVERSE_MEMCRUNCH;
result = handler->OnFinished(this->sourceBase, uPosition++);
}
catch (...)
@ -124,6 +126,8 @@ namespace Aurora::IO::Loop
try
{
AU_DEBUG_REVERSE_MEMCRUNCH;
result = handler->OnFinished(this->sourceBase);
}
catch (...)
@ -158,6 +162,8 @@ namespace Aurora::IO::Loop
{
try
{
AU_DEBUG_REVERSE_MEMCRUNCH;
bShouldRemove &= handler->OnFinished(this->sourceBase);
}
catch (...)
@ -618,17 +624,21 @@ namespace Aurora::IO::Loop
source.source->OnPresleep();
}
auto bRet = WaitAllEx(timeout);
bool bFinished {};
auto bRet = WaitAllEx(timeout, bFinished);
for (const auto &source : this->loopSourceExs_)
if (!bFinished)
{
source.source->OnFinishSleep();
for (const auto &source : this->loopSourceExs_)
{
source.source->OnFinishSleep();
}
}
return bRet;
}
bool LoopQueue::WaitAllEx(AuUInt32 timeout)
bool LoopQueue::WaitAllEx(AuUInt32 timeout, bool &bFinished)
{
bool bReturnStatus {false};
bool bTimeout {false};
@ -674,6 +684,7 @@ namespace Aurora::IO::Loop
}
StartUserAndTakeOwn_Release();
bFinished = true;
return false;
}
}
@ -724,6 +735,7 @@ namespace Aurora::IO::Loop
if (!StartUserAndTakeOwn())
{
StartUserAndTakeOwn_Release();
bFinished = true;
return bReturnStatus;
}
@ -786,6 +798,7 @@ namespace Aurora::IO::Loop
}
}
bFinished = true;
StartUserAndTakeOwn_Release();
return bReturnStatus;
@ -982,17 +995,21 @@ namespace Aurora::IO::Loop
source.source->OnPresleep();
}
auto bRet = WaitAnyNBSpuriousEx(internalEndTime, chuggerIndex, trigger, poll, bTriggerWin32);
bool bFinished {};
auto bRet = WaitAnyNBSpuriousEx(internalEndTime, chuggerIndex, trigger, poll, bTriggerWin32, bFinished);
for (const auto &source : this->loopSourceExs_)
if (!bFinished)
{
source.source->OnFinishSleep();
for (const auto &source : this->loopSourceExs_)
{
source.source->OnFinishSleep();
}
}
return bRet;
}
bool LoopQueue::WaitAnyNBSpuriousEx(AuUInt64 internalEndTime, AuUInt32 &chuggerIndex, AuList<AuSPtr<ILoopSource>> *trigger, bool poll, bool &bTriggerWin32)
bool LoopQueue::WaitAnyNBSpuriousEx(AuUInt64 internalEndTime, AuUInt32 &chuggerIndex, AuList<AuSPtr<ILoopSource>> *trigger, bool poll, bool &bTriggerWin32, bool &bFinished)
{
bool status {};
DWORD temp;
@ -1108,6 +1125,7 @@ namespace Aurora::IO::Loop
{
StartUserAndTakeOwn();
ConsiderEvicitingTimeoutsAll();
bFinished = true;
StartUserAndTakeOwn_Release();
return false;
}
@ -1127,6 +1145,7 @@ namespace Aurora::IO::Loop
if (!StartUserAndTakeOwn())
{
bFinished = true;
StartUserAndTakeOwn_Release();
return true;
}
@ -1288,6 +1307,7 @@ namespace Aurora::IO::Loop
}
bFinished = true;
StartUserAndTakeOwn_Release();
return triggeredCount;
@ -1359,6 +1379,8 @@ namespace Aurora::IO::Loop
{
try
{
AU_DEBUG_REVERSE_MEMCRUNCH;
bShouldRemove &= handler->OnFinished(this->msgSource_);
}
catch (...)
@ -1372,6 +1394,8 @@ namespace Aurora::IO::Loop
{
try
{
AU_DEBUG_REVERSE_MEMCRUNCH;
bShouldRemove &= handler->OnFinished(this->msgSource_, i++);
}
catch (...)
@ -1384,6 +1408,8 @@ namespace Aurora::IO::Loop
{
try
{
AU_DEBUG_REVERSE_MEMCRUNCH;
bShouldRemove &= handler->OnFinished(this->msgSource_);
}
catch (...)
@ -1404,6 +1430,11 @@ namespace Aurora::IO::Loop
void LoopQueue::StartUserAndTakeOwn_Release()
{
this->isCommitableInFuture_ = false;
for (const auto &source : this->loopSourceExs_)
{
source.source->OnFinishSleep();
}
if (this->willCommitInFuture_)
{

View File

@ -42,7 +42,7 @@ namespace Aurora::IO::Loop
AuList<AuSPtr<ILoopSource>> PumpNonblockingEx() override;
bool WaitAll(AuUInt32 timeout) override;
bool WaitAllEx(AuUInt32 timeout);
bool WaitAllEx(AuUInt32 timeout, bool &bFinished);
AuUInt32 WaitAny(AuUInt32 timeout) override;
AuList<AuSPtr<ILoopSource>> WaitAnyEx(AuUInt32 timeout) override;
@ -83,7 +83,7 @@ namespace Aurora::IO::Loop
bool IsValid();
bool RemoveSourceNB(const AuSPtr<ILoopSource> &source);
bool WaitAnyNBSpurious(AuUInt64 internalEndTime, AuUInt32 &chuggerIndex, AuList<AuSPtr<ILoopSource>> *trigger, bool poll, bool &bTriggerWin32);
bool WaitAnyNBSpuriousEx(AuUInt64 internalEndTime, AuUInt32 &chuggerIndex, AuList<AuSPtr<ILoopSource>> *trigger, bool poll, bool &bTriggerWin32);
bool WaitAnyNBSpuriousEx(AuUInt64 internalEndTime, AuUInt32 &chuggerIndex, AuList<AuSPtr<ILoopSource>> *trigger, bool poll, bool &bTriggerWin32, bool &bFinished);
bool ChugWaitAny(AuUInt64 internalEndTime, AuUInt32 &chuggerIndex, AuUInt32 &offset);
bool StartUserAndTakeOwn();