jobqueues having isues with stp

This commit is contained in:
Ryan Ward 2023-07-17 00:44:59 -04:00
parent 9e6552d42e
commit bbaac2d779
5 changed files with 17 additions and 15 deletions

View File

@ -123,10 +123,10 @@ function multi:newSystemThreadedJobQueue(n)
c.cores = n or THREAD.getCores()*2
c.Type = multi.SJOBQUEUE
c.OnJobCompleted = multi:newConnection()
local funcs = multi:newSystemThreadedTable():init()
local queueJob = multi:newSystemThreadedQueue():init()
local queueReturn = multi:newSystemThreadedQueue():init()
local doAll = multi:newSystemThreadedQueue():init()
local funcs = multi:newSystemThreadedTable()
local queueJob = multi:newSystemThreadedQueue()
local queueReturn = multi:newSystemThreadedQueue()
local doAll = multi:newSystemThreadedQueue()
local ID=1
local jid = 1
function c:isEmpty()

View File

@ -62,11 +62,9 @@ function multi:newSystemThreadedTable(name)
self.tab = THREAD.createTable(self.Name)
setmetatable(self,{
__index = function(t, k)
print("Getting...", k)
return self.tab[k]
end,
__newindex = function(t,k,v)
print("Setting...", k, v)
self.tab[k] = v
end
})
@ -85,11 +83,9 @@ function multi:newSystemThreadedTable(name)
setmetatable(c,{
__index = function(t, k)
print("Getting...", k)
return c.tab[k]
end,
__newindex = function(t,k,v)
print("Setting...", k, v)
c.tab[k] = v
end
})

View File

@ -14,7 +14,7 @@ math.random()
math.random()
stab = THREAD.createTable(THREAD_NAME .. THREAD_ID)
if GLOBAL["__env"] then
local env = THREAD.unpackENV(GLOBAL["__env"])
local env = THREAD.getENV()
for i,v in pairs(env) do
_G[i] = v
end

View File

@ -59,17 +59,17 @@ function multi:newProxy(list)
for k, v in pairs(obj) do res[copy(k)] = copy(v) end
return res
end
if not(c.is_init) then
c.is_init = true
if not(self.is_init) then
self.is_init = true
local multi, thread = require("multi"):init()
c.proxy_link = "PL" .. multi.randomString(12)
self.proxy_link = "PL" .. multi.randomString(12)
if multi.integration then
GLOBAL = multi.integration.GLOBAL
THREAD = multi.integration.THREAD
end
GLOBAL[c.proxy_link] = c
GLOBAL[self.proxy_link] = self
local function check()
return self.send:pop()
@ -135,6 +135,7 @@ function multi:newProxy(list)
self.recv = THREAD.waitFor(self.name.."_R"):init()
self.Type = multi.PROXY
for _,v in pairs(funcs) do
print(v,_)
if type(v) == "table" then
-- We have a connection
v[2]:init(proc_name)
@ -280,13 +281,13 @@ function multi:newSystemThreadedProcessor(cores)
end
function c:newFunction(func, holdme)
return c.jobqueue:newFunction(func, holdme)
return self.jobqueue:newFunction(func, holdme)
end
function c:newSharedTable(name)
if not name then multi.error("You must provide a name when creating a table!") end
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()
end, tbl_name, name)
return multi:newSystemThreadedTable(tbl_name):init()

View File

@ -23,8 +23,13 @@ end)
local jq = multi:newSystemThreadedJobQueue(n)
jq:registerFunction("test2",function()
print("This works!")
end)
jq:registerFunction("test",function(a, b, c)
print(a, b+c)
test2()
return a+b+c
end)