bugfixes and useful constants

This commit is contained in:
2026-02-10 21:37:22 +01:00
parent 9c5e4a3d5b
commit ca8387a9e1
5 changed files with 344 additions and 24 deletions

View File

@@ -3,6 +3,7 @@
-- Do not use in a serious context, you will be hacked.
-- There is no sandboxing here.
local sysyieldobj = {}
local function sysyield()
@@ -13,10 +14,7 @@ local resume = coroutine.resume
function coroutine.resume(co, ...)
local t = {resume(co, ...)}
-- NOTE: user can trigger false sysyields
-- by simply yielding an object who's
-- __eql always returns true.
if t[1] and t[2] == sysyieldobj then
if t[1] and rawequal(t[2], sysyieldobj) then
coroutine.yield(sysyieldobj)
else
return table.unpack(t)
@@ -143,6 +141,20 @@ function computer.setArchitecture(arch)
return ok, err
end
function computer.pullSignal(timeout)
timeout = timeout or math.huge
local deadline = computer.uptime() + timeout
while true do
if computer.uptime() >= deadline then return end
local t = {computer.popSignal()}
if #t == 0 then
sysyield()
else
return table.unpack(t)
end
end
end
function checkArg(arg, val, ...)
local t = {...}
for i=1,#t do