Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,14 @@ local stats = {
}

local function doSleep()

local epsilon = 1e-6
local deadline = computer.uptime() + (tonumber(options.i) or tonumber(options.interval) or 1)
repeat
event.pull(deadline - computer.uptime())
until computer.uptime() >= deadline
local remaining = deadline - computer.uptime()
if remaining <= epsilon then break end

event.pull(math.max(remaining, 0.001))
until computer.uptime() >= deadline - epsilon
end

local function doPing()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,13 @@ end
function os.sleep(timeout)
checkArg(1, timeout, "number", "nil")
local deadline = computer.uptime() + (timeout or 0)
local epsilon = 1e-6
repeat
event.pull(deadline - computer.uptime())
until computer.uptime() >= deadline
local remaining = deadline - computer.uptime()
if remaining <= epsilon then break end

event.pull(math.max(remaining, 0.001))
until computer.uptime() >= deadline - epsilon
end

os.setenv("PATH", "/bin:/usr/bin:/home/bin:.")
Expand Down
Loading