1
0
mirror of https://github.com/Adorable-Catgirl/Zorya-NEO.git synced 2024-11-23 10:48:06 +11:00

oops forgot some shit

This commit is contained in:
Jane Roxanne 2020-03-09 22:34:45 -05:00
parent f5c8ccd5a2
commit a246ebcffc
2 changed files with 5 additions and 92 deletions

View File

@ -1,5 +1,10 @@
{ {
{name="zlan", cat="util", path="lib/util_zlan.zy2l"}, {name="zlan", cat="util", path="lib/util_zlan.zy2l"},
{name="cpio", cat="util", path="lib/util_cpio.zy2l"},
{name="urf", cat="util", path="lib/util_urf.zy2l"},
{name="vcomponent", cat="util", path="lib/util_vcomponent.zy2l"},
{name="oefiv2", cat="util", path="mods/util_oefiv2.zy2m"},
{name="oefiv1", cat="util", path="mods/util_oefiv1.zy2m"},
{name="openos", cat="loader", path="mods/loader_openos.zy2m"}, {name="openos", cat="loader", path="mods/loader_openos.zy2m"},
{name="fuchas", cat="loader", path="mods/loader_fuchas.zy2m"}, {name="fuchas", cat="loader", path="mods/loader_fuchas.zy2m"},
--{name="tsuki", cat="loader", path="mods/loader_tsuki.zy2m"}, --{name="tsuki", cat="loader", path="mods/loader_tsuki.zy2m"},

View File

@ -1,92 +0,0 @@
local thd = {}
local threads = {}
local idx = 1
local computer = computer
local unpack = unpack or table.unpack
local coroutine = coroutine
local c_create = coroutine.create
local c_yield = coroutine.yield
local c_resume = coroutine.resume
local c_status = coroutine.status
function thd.add(name, func)
local t = assert(c_create(func))
--component.proxy(component.list("sandbox")()).debug_log(name, t, func)
threads[#threads+1] = {name, t, {}, 0, ".+"}
threads[t] = threads[#threads]
end
local sigs = {}
local ps = computer.pullSignal
function thd.autosleep()
local msleep = math.huge
for i=1, #threads do
if (threads[i][4] and threads[i][4] < msleep) then
msleep = threads[i][4]
end
end
local rsleep = msleep-computer.uptime()
if (rsleep < 0 or #sigs > 0) then
rsleep = 0
end
local sig = {ps(rsleep)}
if (#sigs > 0) then
if (#sig > 0) then
sigs[#sigs+1] = sig
end
sig = sigs[1]
table.remove(sigs, 1)
end
return sig
end
local last_sig = {}
function thd.run()
last_sig = thd.autosleep()
for i=1, #threads do
if (threads[i][4] <= computer.uptime() or #last_sig > 0) then
if (c_status(threads[i][2]) ~= "running") then
local er, dl = c_resume(threads[i][2], unpack(last_sig))
if (not er) then error(threads[i][1]..": "..dl) end
if (dl == "k") then
threads[i][6] = true
end
dl = computer.uptime() + (dl or math.huge)
threads[i][4] = dl
sigs[#sigs+1] = {ps(0)}
end
end
end
local t = {}
for i=1, #threads do
local v = threads[i]
if (c_status(v[2]) ~= "dead" and not v[6]) then
t[#t+1] = v
t[v[2]] = v
end
end
threads = t
return #threads > 0
end
function thd.kill(i)
threads[i][6] = true
end
function thd.sched_end()
return #threads == idx
end
function thd.get_threads()
return threads
end
function computer.pullSignal(t)
return c_yield(t)
end
return thd