Working on adding a Hold method to all objects. Will document how they all work when done.

This commit is contained in:
2023-07-16 11:10:35 -04:00
parent afdd98ab13
commit 9e6552d42e
5 changed files with 308 additions and 55 deletions
+28
View File
@@ -58,6 +58,19 @@ function multi:newSystemThreadedQueue(name)
GLOBAL[name] = c
end
function c:Hold(opt)
local multi, thread = require("multi"):init()
if opt.peek then
return thread.hold(function()
return self:peek()
end)
else
return thread.hold(function()
return self:pop()
end)
end
end
self:create(c)
return c
@@ -89,6 +102,17 @@ function multi:newSystemThreadedTable(name)
GLOBAL[name] = c
end
function c:Hold(opt)
local multi, thread = require("multi"):init()
if opt.key then
return thread.hold(function()
return self.tab[opt.key]
end)
else
multi.error("Must provide a key to check opt.key = 'key'")
end
end
self:create(c)
return c
@@ -214,6 +238,10 @@ function multi:newSystemThreadedJobQueue(n)
end,i).OnError(multi.error)
end
function c:Hold(opt)
return thread.hold(self.OnJobCompleted)
end
self:create(c)
return c