[*] Minor WaitMultipleLoopSources optimization

This commit is contained in:
Reece Wilson 2023-12-02 18:14:14 +00:00
parent baf31e32d0
commit e60e308087

View File

@ -110,7 +110,8 @@ namespace Aurora::IO::Loop
auto pSource = lsList[0];
if (!pSource)
{
return false;
signaled.push_back({});
return true;
}
bool bStatus {};
@ -253,13 +254,20 @@ namespace Aurora::IO::Loop
auto lsList2 = lsList;
bool bAnyFound {};
auto DoTheThing = [&]()
auto DoTheThing = [&](bool bLastTick)
{
for (auto itr = lsList2.begin();
itr != lsList2.end();
)
{
auto pSource = *itr;
if (!pSource)
{
signalTemp.push_back({});
itr = lsList2.erase(itr);
continue;
}
auto eType = pSource->GetType();
if (eType == ELoopSource::eSourceMutex ||
@ -278,7 +286,14 @@ namespace Aurora::IO::Loop
}
else
{
itr++;
if (bLastTick && bZeroTick)
{
itr = lsList2.erase(itr);
}
else
{
itr++;
}
}
}
else
@ -293,19 +308,19 @@ namespace Aurora::IO::Loop
{
AuThreadPrimitives::DoTryIf([&]()
{
DoTheThing();
DoTheThing(false);
return lsList2.size() != lsList.size() ||
!bAnyFound;
});
if (bAnyFound)
{
DoTheThing();
DoTheThing(true);
}
}
else
{
DoTheThing();
DoTheThing(true);
}
if (lsList2.size())