diff --git a/Source/IO/Loop/Loop.NT.cpp b/Source/IO/Loop/Loop.NT.cpp index 469a76b9..d62df28b 100644 --- a/Source/IO/Loop/Loop.NT.cpp +++ b/Source/IO/Loop/Loop.NT.cpp @@ -126,15 +126,27 @@ namespace Aurora::IO::Loop AuUInt lastHandle {}; bool wasTriggered {}; - // first handle in group - for (const auto &handle : source->GetHandles()) + if (source->Singular()) { + auto handle = source->GetHandle(); if ((firstTriggered == handle) || (bAllowOthers && WaitForSingleObject(reinterpret_cast(handle), 0) == WAIT_OBJECT_0)) { lastHandle = handle; wasTriggered = true; - continue; + } + } + else + { + for (const auto &handle : source->GetHandles()) + { + if ((firstTriggered == handle) || + (bAllowOthers && WaitForSingleObject(reinterpret_cast(handle), 0) == WAIT_OBJECT_0)) + { + lastHandle = handle; + wasTriggered = true; + break; + } } } diff --git a/Source/IO/Loop/Loop.cpp b/Source/IO/Loop/Loop.cpp index c4e25957..16e179c1 100644 --- a/Source/IO/Loop/Loop.cpp +++ b/Source/IO/Loop/Loop.cpp @@ -375,46 +375,50 @@ namespace Aurora::IO::Loop { bZeroTick |= bool(signalTemp.size()); AuUInt32 uTimeoutMS {}; - - if (uTimeoutEnd) - { - auto uStartTime = Time::SteadyClockNS(); - if (uStartTime >= uTimeoutEnd) - { - bZeroTick = true; - } - - uTimeoutMS = AuNSToMS(uTimeoutEnd - uStartTime); - if (!uTimeoutMS) - { - bZeroTick = true; - } - } - bool bTooMany {}; - #if defined(AURORA_IS_MODERNNT_DERIVED) - if (AuBuild::kCurrentVendor == AuBuild::EVendor::eGenericMicrosoft && - lsList2.size() < MAXIMUM_WAIT_OBJECTS) + + do { - signaled = WaitMultipleOrObjects(lsList2, bZeroTick, uTimeoutMS, bAllowOthers, bTooMany); - bTimedout = uTimeoutEnd && uTimeoutMS && !bZeroTick ? - Time::SteadyClockNS() >= uTimeoutEnd : - false; - } - else - #elif defined(AURORA_IS_POSIX_DERIVED) - if (true) - { - signaled = WaitMultipleOrObjects(lsList2, bZeroTick, uTimeoutMS, bAllowOthers, bTooMany); - bTimedout = uTimeoutEnd && uTimeoutMS && !bZeroTick ? - Time::SteadyClockNS() >= uTimeoutEnd : - false; - } - else - #endif - { - bTooMany = true; + if (uTimeoutEnd) + { + auto uStartTime = Time::SteadyClockNS(); + if (uStartTime >= uTimeoutEnd) + { + bZeroTick = true; + } + + uTimeoutMS = AuNSToMS(uTimeoutEnd - uStartTime); + if (!uTimeoutMS) + { + bZeroTick = true; + } + } + + #if defined(AURORA_IS_MODERNNT_DERIVED) + if (AuBuild::kCurrentVendor == AuBuild::EVendor::eGenericMicrosoft && + lsList2.size() < MAXIMUM_WAIT_OBJECTS) + { + signaled = WaitMultipleOrObjects(lsList2, bZeroTick, uTimeoutMS, bAllowOthers, bTooMany); + bTimedout = uTimeoutEnd && uTimeoutMS && !bZeroTick ? + Time::SteadyClockNS() >= uTimeoutEnd : + false; + } + else + #elif defined(AURORA_IS_POSIX_DERIVED) + if (true) + { + signaled = WaitMultipleOrObjects(lsList2, bZeroTick, uTimeoutMS, bAllowOthers, bTooMany); + bTimedout = uTimeoutEnd && uTimeoutMS && !bZeroTick ? + Time::SteadyClockNS() >= uTimeoutEnd : + false; + } + else + #endif + { + bTooMany = true; + } } + while (!bTimedout && !bTooMany && signaled.empty()); if (bTooMany) {