summaryrefslogtreecommitdiff
path: root/queue.lua
diff options
context:
space:
mode:
authorubq323 <ubq323@ubq323.website>2025-02-25 23:43:41 +0000
committerubq323 <ubq323@ubq323.website>2025-02-25 23:43:41 +0000
commit4dec20e4ff11b61be57a6cfbdb289327d9e1eb7d (patch)
treecc2ffe0357c1110236270ad46dc2006cdb01bf89 /queue.lua
parente03937bbe51f3dd8e0d8ecc732999f5c4578fa94 (diff)
the Restructuring
Diffstat (limited to 'queue.lua')
-rw-r--r--queue.lua39
1 files changed, 0 insertions, 39 deletions
diff --git a/queue.lua b/queue.lua
deleted file mode 100644
index 8c9c373..0000000
--- a/queue.lua
+++ /dev/null
@@ -1,39 +0,0 @@
-local cqueues = require'cqueues'
-local condition = require'cqueues.condition'
-local cqaux = require'cqueues.auxlib'
-
-local Queue = {}
-
-function Queue.make()
- return setmetatable({
- items = {},
- cv = condition.new(),
- }, {__index=Queue})
-end
-
-function Queue.enqueue(self, ...)
- local item = table.pack(...)
- table.insert(self.items, item)
- if #self.items > 128 then
- print('warning: queue is quite big')
- end
- self.cv:signal()
-end
-
-function Queue.iter(self)
- return cqaux.wrap(function()
- while true do
- while #self.items > 0 do
- local items = self.items
- self.items = {} -- the old switcheroo
- for _, item in ipairs(items) do
- coroutine.yield(table.unpack(item, 1, item.n))
- end
- end
- self.cv:wait()
- end
- end)
-end
-
-
-return Queue