Timer: Spin for last 1ms on non-windows too

This commit is contained in:
Connor McLaughlin 2022-08-10 13:02:23 +10:00
parent 73a80d3a1d
commit ae0d60fcd8
1 changed files with 15 additions and 2 deletions

View File

@ -186,8 +186,21 @@ void Timer::SleepUntil(Value value, bool exact)
{ {
if (exact) if (exact)
{ {
while (GetCurrentValue() < value) for (;;)
SleepUntil(value, false); {
Value current = GetCurrentValue();
if (current >= value)
break;
static constexpr Value min_sleep_time = 1 * 1000000;
// spin for the last 1ms
if ((value - current) > min_sleep_time)
{
SleepUntil(value, false);
continue;
}
}
} }
else else
{ {