-- :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")