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