restructure for spm

This commit is contained in:
2026-01-18 22:14:15 -05:00
parent fd7ee1aa3b
commit 63bcc2df5c
68 changed files with 120 additions and 98 deletions

View File

@@ -0,0 +1,42 @@
--:Minify:--
local kernel=...
local io = {}
kernel.io=io
io.eventq={}
function io.pushEvent(queue, ...)
queue=tostring(queue)
if not io.eventq[queue] then
io.eventq[queue]={}
end
io.eventq[queue][#io.eventq[queue]+1]={...}
end
function io.bind(queue)
queue=tostring(queue)
kernel.currentTask.eventq=queue
end
function io.pullEvent()
if io.eventq[kernel.currentTask.eventq] then
if #io.eventq[kernel.currentTask.eventq]==1 then
local event = table.remove(io.eventq[kernel.currentTask.eventq] or {}, 1)
io.eventq[kernel.currentTask.eventq]=nil
return table.unpack(event)
end
local event = table.remove(io.eventq[kernel.currentTask.eventq] or {}, 1)
if not event then return end
return table.unpack(event)
end
end
function io.getBoundQueue()
return kernel.currentTask.eventq
end
kernel.syscalls["IO_pushEvent"]=io.pushEvent
kernel.syscalls["IO_pullEvent"]=io.pullEvent
kernel.syscalls["IO_bind"]=io.bind
kernel.syscalls["IO_getBoundQueue"]=io.getBoundQueue
kernel.log("IO pipeline initialized")