Fix busy wait when tick == 0 (#1206)

This commit is contained in:
Tim Wilkinson 2024-05-15 18:09:07 -07:00 committed by GitHub
parent b495f4e62b
commit 250db5605f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 12 additions and 8 deletions

View File

@ -51,15 +51,19 @@ if nixio.sysinfo().totalram < 32 * 1024 * 1024 then
end
function wait_for_ticks(ticks)
local when = nixio.sysinfo().uptime + ticks
while true
do
if ticks >= 0 then
coroutine.yield(ticks)
else
break
if ticks <= 0 then
coroutine.yield(0)
else
local when = nixio.sysinfo().uptime + ticks
while true
do
if ticks > 0 then
coroutine.yield(ticks)
else
break
end
ticks = when - nixio.sysinfo().uptime
end
ticks = when - nixio.sysinfo().uptime
end
end