jobqueues having isues with stp
This commit is contained in:
parent
9e6552d42e
commit
bbaac2d779
@ -123,10 +123,10 @@ function multi:newSystemThreadedJobQueue(n)
|
|||||||
c.cores = n or THREAD.getCores()*2
|
c.cores = n or THREAD.getCores()*2
|
||||||
c.Type = multi.SJOBQUEUE
|
c.Type = multi.SJOBQUEUE
|
||||||
c.OnJobCompleted = multi:newConnection()
|
c.OnJobCompleted = multi:newConnection()
|
||||||
local funcs = multi:newSystemThreadedTable():init()
|
local funcs = multi:newSystemThreadedTable()
|
||||||
local queueJob = multi:newSystemThreadedQueue():init()
|
local queueJob = multi:newSystemThreadedQueue()
|
||||||
local queueReturn = multi:newSystemThreadedQueue():init()
|
local queueReturn = multi:newSystemThreadedQueue()
|
||||||
local doAll = multi:newSystemThreadedQueue():init()
|
local doAll = multi:newSystemThreadedQueue()
|
||||||
local ID=1
|
local ID=1
|
||||||
local jid = 1
|
local jid = 1
|
||||||
function c:isEmpty()
|
function c:isEmpty()
|
||||||
|
|||||||
@ -62,11 +62,9 @@ function multi:newSystemThreadedTable(name)
|
|||||||
self.tab = THREAD.createTable(self.Name)
|
self.tab = THREAD.createTable(self.Name)
|
||||||
setmetatable(self,{
|
setmetatable(self,{
|
||||||
__index = function(t, k)
|
__index = function(t, k)
|
||||||
print("Getting...", k)
|
|
||||||
return self.tab[k]
|
return self.tab[k]
|
||||||
end,
|
end,
|
||||||
__newindex = function(t,k,v)
|
__newindex = function(t,k,v)
|
||||||
print("Setting...", k, v)
|
|
||||||
self.tab[k] = v
|
self.tab[k] = v
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
@ -85,11 +83,9 @@ function multi:newSystemThreadedTable(name)
|
|||||||
|
|
||||||
setmetatable(c,{
|
setmetatable(c,{
|
||||||
__index = function(t, k)
|
__index = function(t, k)
|
||||||
print("Getting...", k)
|
|
||||||
return c.tab[k]
|
return c.tab[k]
|
||||||
end,
|
end,
|
||||||
__newindex = function(t,k,v)
|
__newindex = function(t,k,v)
|
||||||
print("Setting...", k, v)
|
|
||||||
c.tab[k] = v
|
c.tab[k] = v
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|||||||
@ -14,7 +14,7 @@ math.random()
|
|||||||
math.random()
|
math.random()
|
||||||
stab = THREAD.createTable(THREAD_NAME .. THREAD_ID)
|
stab = THREAD.createTable(THREAD_NAME .. THREAD_ID)
|
||||||
if GLOBAL["__env"] then
|
if GLOBAL["__env"] then
|
||||||
local env = THREAD.unpackENV(GLOBAL["__env"])
|
local env = THREAD.getENV()
|
||||||
for i,v in pairs(env) do
|
for i,v in pairs(env) do
|
||||||
_G[i] = v
|
_G[i] = v
|
||||||
end
|
end
|
||||||
|
|||||||
@ -59,17 +59,17 @@ function multi:newProxy(list)
|
|||||||
for k, v in pairs(obj) do res[copy(k)] = copy(v) end
|
for k, v in pairs(obj) do res[copy(k)] = copy(v) end
|
||||||
return res
|
return res
|
||||||
end
|
end
|
||||||
if not(c.is_init) then
|
if not(self.is_init) then
|
||||||
c.is_init = true
|
self.is_init = true
|
||||||
local multi, thread = require("multi"):init()
|
local multi, thread = require("multi"):init()
|
||||||
c.proxy_link = "PL" .. multi.randomString(12)
|
self.proxy_link = "PL" .. multi.randomString(12)
|
||||||
|
|
||||||
if multi.integration then
|
if multi.integration then
|
||||||
GLOBAL = multi.integration.GLOBAL
|
GLOBAL = multi.integration.GLOBAL
|
||||||
THREAD = multi.integration.THREAD
|
THREAD = multi.integration.THREAD
|
||||||
end
|
end
|
||||||
|
|
||||||
GLOBAL[c.proxy_link] = c
|
GLOBAL[self.proxy_link] = self
|
||||||
|
|
||||||
local function check()
|
local function check()
|
||||||
return self.send:pop()
|
return self.send:pop()
|
||||||
@ -135,6 +135,7 @@ function multi:newProxy(list)
|
|||||||
self.recv = THREAD.waitFor(self.name.."_R"):init()
|
self.recv = THREAD.waitFor(self.name.."_R"):init()
|
||||||
self.Type = multi.PROXY
|
self.Type = multi.PROXY
|
||||||
for _,v in pairs(funcs) do
|
for _,v in pairs(funcs) do
|
||||||
|
print(v,_)
|
||||||
if type(v) == "table" then
|
if type(v) == "table" then
|
||||||
-- We have a connection
|
-- We have a connection
|
||||||
v[2]:init(proc_name)
|
v[2]:init(proc_name)
|
||||||
@ -280,13 +281,13 @@ function multi:newSystemThreadedProcessor(cores)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function c:newFunction(func, holdme)
|
function c:newFunction(func, holdme)
|
||||||
return c.jobqueue:newFunction(func, holdme)
|
return self.jobqueue:newFunction(func, holdme)
|
||||||
end
|
end
|
||||||
|
|
||||||
function c:newSharedTable(name)
|
function c:newSharedTable(name)
|
||||||
if not name then multi.error("You must provide a name when creating a table!") end
|
if not name then multi.error("You must provide a name when creating a table!") end
|
||||||
local tbl_name = "TABLE_"..multi.randomString(8)
|
local tbl_name = "TABLE_"..multi.randomString(8)
|
||||||
c.jobqueue:doToAll(function(tbl_name, interaction)
|
self.jobqueue:doToAll(function(tbl_name, interaction)
|
||||||
_G[interaction] = THREAD.waitFor(tbl_name):init()
|
_G[interaction] = THREAD.waitFor(tbl_name):init()
|
||||||
end, tbl_name, name)
|
end, tbl_name, name)
|
||||||
return multi:newSystemThreadedTable(tbl_name):init()
|
return multi:newSystemThreadedTable(tbl_name):init()
|
||||||
|
|||||||
@ -23,8 +23,13 @@ end)
|
|||||||
|
|
||||||
local jq = multi:newSystemThreadedJobQueue(n)
|
local jq = multi:newSystemThreadedJobQueue(n)
|
||||||
|
|
||||||
|
jq:registerFunction("test2",function()
|
||||||
|
print("This works!")
|
||||||
|
end)
|
||||||
|
|
||||||
jq:registerFunction("test",function(a, b, c)
|
jq:registerFunction("test",function(a, b, c)
|
||||||
print(a, b+c)
|
print(a, b+c)
|
||||||
|
test2()
|
||||||
return a+b+c
|
return a+b+c
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user