diff --git a/Source/IO/Loop/LoopQueue.NT.cpp b/Source/IO/Loop/LoopQueue.NT.cpp index 62471501..1d636d6f 100644 --- a/Source/IO/Loop/LoopQueue.NT.cpp +++ b/Source/IO/Loop/LoopQueue.NT.cpp @@ -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> *trigger, bool poll, bool &bTriggerWin32) + bool LoopQueue::WaitAnyNBSpuriousEx(AuUInt64 internalEndTime, AuUInt32 &chuggerIndex, AuList> *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_) { diff --git a/Source/IO/Loop/LoopQueue.NT.hpp b/Source/IO/Loop/LoopQueue.NT.hpp index 44d68f96..6118326d 100644 --- a/Source/IO/Loop/LoopQueue.NT.hpp +++ b/Source/IO/Loop/LoopQueue.NT.hpp @@ -42,7 +42,7 @@ namespace Aurora::IO::Loop AuList> PumpNonblockingEx() override; bool WaitAll(AuUInt32 timeout) override; - bool WaitAllEx(AuUInt32 timeout); + bool WaitAllEx(AuUInt32 timeout, bool &bFinished); AuUInt32 WaitAny(AuUInt32 timeout) override; AuList> WaitAnyEx(AuUInt32 timeout) override; @@ -83,7 +83,7 @@ namespace Aurora::IO::Loop bool IsValid(); bool RemoveSourceNB(const AuSPtr &source); bool WaitAnyNBSpurious(AuUInt64 internalEndTime, AuUInt32 &chuggerIndex, AuList> *trigger, bool poll, bool &bTriggerWin32); - bool WaitAnyNBSpuriousEx(AuUInt64 internalEndTime, AuUInt32 &chuggerIndex, AuList> *trigger, bool poll, bool &bTriggerWin32); + bool WaitAnyNBSpuriousEx(AuUInt64 internalEndTime, AuUInt32 &chuggerIndex, AuList> *trigger, bool poll, bool &bTriggerWin32, bool &bFinished); bool ChugWaitAny(AuUInt64 internalEndTime, AuUInt32 &chuggerIndex, AuUInt32 &offset); bool StartUserAndTakeOwn();