mirror of
https://github.com/rayaman/multi.git
synced 2026-09-05 07:27:35 -04:00
Working on adding a Hold method to all objects. Will document how they all work when done.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user