[*] Make WaitForMultipleAddressesAnds return logic more explicit / clearer

This commit is contained in:
Reece Wilson 2024-11-29 11:58:33 +00:00
parent 9711061dab
commit d7a27f1a7d

View File

@ -1973,13 +1973,12 @@ namespace Aurora::Threading
pCurrent->uOldStateChangedCounter = current.uHasStateChangedCounter;
}
bool bFound {};
bool bTimeout {};
bool bFoundNotTriggered {}, bTimeout {}, bStatus {};
do
{
bool bRet = WaitForMultipleAddressesOr(waitMultipleOnAddress);
bFound = false;
bFoundNotTriggered = false;
for (AU_ITERATE_N(i, uCount))
{
@ -1999,7 +1998,7 @@ namespace Aurora::Threading
}
else
{
bFound = true;
bFoundNotTriggered = true;
}
}
@ -2009,7 +2008,16 @@ namespace Aurora::Threading
break;
}
}
while (bFound);
while (bFoundNotTriggered);
if (bTimeout)
{
bStatus = false;
}
else
{
bStatus = !bFoundNotTriggered;
}
for (AU_ITERATE_N(i, uCount))
{
@ -2017,16 +2025,15 @@ namespace Aurora::Threading
auto pCurrent = AuReinterpretCast<MultipleInternalContext>(pBase[i].internalContext);
current.bIgnoreCurrentFlag = pCurrent->bOldIgnore;
current.uHasStateChangedCounter = pCurrent->uOldStateChangedCounter + (bFound ? 0 : 1);
if (current.bIgnoreCurrentFlag)
{
continue;
}
current.uHasStateChangedCounter = pCurrent->uOldStateChangedCounter + (bStatus ? 1 : 0);
}
if (!bFound)
{
return true;
}
else
{
return !bTimeout;
}
return bStatus;
}
}