|
|
|
|
@ -1,8 +1,10 @@
|
|
|
|
|
// SPDX-FileCopyrightText: 2019-2024 Connor McLaughlin <stenzek@gmail.com>
|
|
|
|
|
// SPDX-FileCopyrightText: 2019-2026 Connor McLaughlin <stenzek@gmail.com>
|
|
|
|
|
// SPDX-License-Identifier: CC-BY-NC-ND-4.0
|
|
|
|
|
|
|
|
|
|
#include "timer.h"
|
|
|
|
|
#include "intrin.h"
|
|
|
|
|
#include "types.h"
|
|
|
|
|
|
|
|
|
|
#include <cstdio>
|
|
|
|
|
#include <cstdlib>
|
|
|
|
|
|
|
|
|
|
@ -117,13 +119,17 @@ void Timer::SleepUntil(Value value, bool exact)
|
|
|
|
|
const Value wake_at = value - ConvertMillisecondsToValue(0.5);
|
|
|
|
|
Value current = GetCurrentValue();
|
|
|
|
|
if (wake_at > current)
|
|
|
|
|
{
|
|
|
|
|
SleepUntil(wake_at, false);
|
|
|
|
|
current = GetCurrentValue();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// And spin off whatever time is left.
|
|
|
|
|
do
|
|
|
|
|
while (current < value)
|
|
|
|
|
{
|
|
|
|
|
MultiPause();
|
|
|
|
|
current = GetCurrentValue();
|
|
|
|
|
} while (current < value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
@ -205,13 +211,17 @@ void Timer::SleepUntil(Value value, bool exact)
|
|
|
|
|
const Value wake_at = value - min_sleep_time;
|
|
|
|
|
Value current = GetCurrentValue();
|
|
|
|
|
if (wake_at > current)
|
|
|
|
|
{
|
|
|
|
|
SleepUntil(wake_at, false);
|
|
|
|
|
current = GetCurrentValue();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// And spin off whatever time is left.
|
|
|
|
|
do
|
|
|
|
|
while (current < value)
|
|
|
|
|
{
|
|
|
|
|
MultiPause();
|
|
|
|
|
current = GetCurrentValue();
|
|
|
|
|
} while (current < value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
|