[*] Fix bugs in the partially rewritten async scheduler

This commit is contained in:
Reece Wilson 2023-12-06 17:29:31 +00:00
parent 8b4ad9795c
commit e853b44ee6

View File

@ -50,6 +50,7 @@ namespace Aurora::Async
if (ns > time)
{
SchedNextTime(ns);
break;
}
@ -79,8 +80,6 @@ namespace Aurora::Async
static void SchedNextTime(AuUInt64 uNSAbs)
{
bool bForceWakeup {};
if (uNextSysTickGuessed > uNSAbs ||
!uNextSysTickGuessed)
{
@ -99,21 +98,13 @@ namespace Aurora::Async
uNSAbs = uNextWakeuptimeRateLimit;
}
if (!uCurrent)
{
bForceWakeup = true;
}
if (AuAtomicCompareExchange(&uNextSysTickGuessed, uNSAbs, uCurrent) == uCurrent)
{
break;
}
}
if (bForceWakeup)
{
gSchedCondvar->Signal();
}
gSchedCondvar->Signal();
}
}
@ -136,15 +127,15 @@ namespace Aurora::Async
if (uNow < uNextTick)
{
uNextSysTickGuessed = 0;
gSchedCondvar->WaitForSignalNS(uNextTick - uNow);
}
else if (uNow == uNextTick)
else if (uNow >= uNextTick)
{
uNextSysTickGuessed = 0;
}
else
else if (uNextSysTickGuessed == 0)
{
uNextSysTickGuessed = 0;
gSchedCondvar->WaitForSignalNS(gRuntimeConfig.async.bEnableLegacyTicks ?
AuMSToNS<AuUInt64>(gRuntimeConfig.async.dwLegacyMainThreadSystemTickMS) :
0);
@ -278,7 +269,7 @@ namespace Aurora::Async
}
else
{
itr ++;
itr++;
}
}
}