local condition = require("cqueues.condition") local fifo = {} function fifo.new() return setmetatable({ cond = condition.new() }, { __index = fifo }) end function fifo.signal(f) f.cond:signal() end function fifo.get(f) if not f.head then f.cond:wait() end local data = f.head.data f.head = f.head.tail return data end function fifo.put(f, data) f.head = { data = data, tail = f.head } fifo.signal(f) end function fifo.iter(f) return function () return fifo.get(f) end end return fifo