[*] WaitMultipleLoopSourcesEx (any) fixes

This commit is contained in:
Reece Wilson 2024-09-09 12:40:49 +01:00
parent 634eb35959
commit e62a99777f
2 changed files with 56 additions and 40 deletions

View File

@ -126,15 +126,27 @@ namespace Aurora::IO::Loop
AuUInt lastHandle {}; AuUInt lastHandle {};
bool wasTriggered {}; bool wasTriggered {};
// first handle in group if (source->Singular())
for (const auto &handle : source->GetHandles())
{ {
auto handle = source->GetHandle();
if ((firstTriggered == handle) || if ((firstTriggered == handle) ||
(bAllowOthers && WaitForSingleObject(reinterpret_cast<HANDLE>(handle), 0) == WAIT_OBJECT_0)) (bAllowOthers && WaitForSingleObject(reinterpret_cast<HANDLE>(handle), 0) == WAIT_OBJECT_0))
{ {
lastHandle = handle; lastHandle = handle;
wasTriggered = true; wasTriggered = true;
continue; }
}
else
{
for (const auto &handle : source->GetHandles())
{
if ((firstTriggered == handle) ||
(bAllowOthers && WaitForSingleObject(reinterpret_cast<HANDLE>(handle), 0) == WAIT_OBJECT_0))
{
lastHandle = handle;
wasTriggered = true;
break;
}
} }
} }

View File

@ -375,46 +375,50 @@ namespace Aurora::IO::Loop
{ {
bZeroTick |= bool(signalTemp.size()); bZeroTick |= bool(signalTemp.size());
AuUInt32 uTimeoutMS {}; AuUInt32 uTimeoutMS {};
if (uTimeoutEnd)
{
auto uStartTime = Time::SteadyClockNS();
if (uStartTime >= uTimeoutEnd)
{
bZeroTick = true;
}
uTimeoutMS = AuNSToMS<AuInt64>(uTimeoutEnd - uStartTime);
if (!uTimeoutMS)
{
bZeroTick = true;
}
}
bool bTooMany {}; bool bTooMany {};
#if defined(AURORA_IS_MODERNNT_DERIVED)
if (AuBuild::kCurrentVendor == AuBuild::EVendor::eGenericMicrosoft && do
lsList2.size() < MAXIMUM_WAIT_OBJECTS)
{ {
signaled = WaitMultipleOrObjects(lsList2, bZeroTick, uTimeoutMS, bAllowOthers, bTooMany); if (uTimeoutEnd)
bTimedout = uTimeoutEnd && uTimeoutMS && !bZeroTick ? {
Time::SteadyClockNS() >= uTimeoutEnd : auto uStartTime = Time::SteadyClockNS();
false; if (uStartTime >= uTimeoutEnd)
} {
else bZeroTick = true;
#elif defined(AURORA_IS_POSIX_DERIVED) }
if (true)
{ uTimeoutMS = AuNSToMS<AuInt64>(uTimeoutEnd - uStartTime);
signaled = WaitMultipleOrObjects(lsList2, bZeroTick, uTimeoutMS, bAllowOthers, bTooMany); if (!uTimeoutMS)
bTimedout = uTimeoutEnd && uTimeoutMS && !bZeroTick ? {
Time::SteadyClockNS() >= uTimeoutEnd : bZeroTick = true;
false; }
} }
else
#endif #if defined(AURORA_IS_MODERNNT_DERIVED)
{ if (AuBuild::kCurrentVendor == AuBuild::EVendor::eGenericMicrosoft &&
bTooMany = true; 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) if (bTooMany)
{ {