Working on getting pseudoThreading tests to work

This commit is contained in:
2023-10-15 13:21:57 -04:00
parent ad929da484
commit ef7464f70d
14 changed files with 1150 additions and 28 deletions
+5 -5
View File
@@ -207,9 +207,9 @@ function multi:newSystemThreadedJobQueue(n)
local jid = table.remove(dat, 1)
local args = table.remove(dat, 1)
queueReturn:push{jid, funcs[name](args[1],args[2],args[3],args[4],args[5],args[6],args[7],args[8]), queue}
end).OnError(multi.error)
end)
end
end).OnError(multi.error)
end)
thread:newThread("DoAllHandler",function()
while true do
local dat = thread.hold(function()
@@ -225,7 +225,7 @@ function multi:newSystemThreadedJobQueue(n)
end
end
end
end).OnError(multi.error)
end)
thread:newThread("IdleHandler",function()
while true do
thread.hold(function()
@@ -233,9 +233,9 @@ function multi:newSystemThreadedJobQueue(n)
end)
THREAD.sleep(.01)
end
end).OnError(multi.error)
end)
multi:mainloop()
end,i).OnError(multi.error)
end,i)
end
function c:Hold(opt)
+1
View File
@@ -130,6 +130,7 @@ function multi:newSystemThread(name, func, ...)
c.OnDeath = multi:newConnection()
c.OnError = multi:newConnection()
GLOBAL["__THREADS__"] = livingThreads
c.OnError(multi.error)
if self.isActor then
self:create(c)
+3 -1
View File
@@ -172,6 +172,7 @@ function multi:newSystemThreadedJobQueue(n)
multi:newSystemThread("JobQueue_"..jqc.."_worker_"..i,function(jqc)
local multi, thread = require("multi"):init()
require("love.timer")
love.timer.sleep(1)
local clock = os.clock
local funcs = THREAD.createTable("__JobQueue_"..jqc.."_table")
local queue = THREAD.waitFor("__JobQueue_"..jqc.."_queue")
@@ -208,11 +209,12 @@ function multi:newSystemThreadedJobQueue(n)
local id = table.remove(dat,1)
local tab = {funcs[name](multi.unpack(dat))}
table.insert(tab,1,id)
--local test = queueReturn.push
queueReturn:push(tab)
end)
end
end
end).OnError(multi.error)
end)
thread:newThread("Idler",function()
while true do
thread.yield()
+2
View File
@@ -60,6 +60,8 @@ function multi:newSystemThread(name, func, ...)
table.insert(threads, c)
c.OnError(multi.error)
if self.isActor then
self:create(c)
else
+2 -2
View File
@@ -300,7 +300,7 @@ function multi:newSystemThreadedConnection(name)
-- This shouldn't be the case
end
end
end).OnError(multi.error)
end)
return self
end
@@ -377,7 +377,7 @@ function multi:newSystemThreadedConnection(name)
c.proxy_conn:Fire(multi.unpack(item[2]))
end
end
end).OnError(multi.error)
end)
--- ^^^ This will only exist in the init thread
THREAD.package(name,c)
+2
View File
@@ -104,6 +104,8 @@ function multi:newSystemThread(name, func, ...)
c.stab.returns = nil
end
end)
c.OnError(multi.error)
if self.isActor then
self:create(c)
+1 -1
View File
@@ -210,7 +210,7 @@ local function init_chronos()
thread.yield()
priorityManager.run()
end
end).OnError(multi.error)
end)
end
if chronos then
+5 -3
View File
@@ -35,15 +35,16 @@ end
function multi:newSystemThreadedQueue(name)
local c = {}
c.data = {}
c.Type = multi.registerType("s_queue")
function c:push(v)
table.insert(self,v)
end
function c:pop()
return table.remove(self,1)
return table.remove(self.data,1)
end
function c:peek()
return self[1]
return self.data[1]
end
function c:init()
return self
@@ -156,6 +157,7 @@ function multi:newSystemThreadedJobQueue(n)
end)
for i=1,c.cores do
multi:newSystemThread("JobQueue_"..jqc.."_worker_"..i,function(jqc)
local GLOBAL, THREAD = require("multi.integration.pseudoManager"):init()
local multi, thread = require("multi"):init()
local clock = os.clock
local funcs = THREAD.waitFor("__JobQueue_"..jqc.."_table")
@@ -197,7 +199,7 @@ function multi:newSystemThreadedJobQueue(n)
end)
end
end
end).OnError(multi.error)
end)
thread:newThread("Idler",function()
while true do
thread.yield()
+1
View File
@@ -92,6 +92,7 @@ function multi:newSystemThread(name, func, ...)
local th = thread:newISOThread(name, func, env, ...)
th.Type = multi.registerType("s_thread", "pseudoThreads")
th.OnError(multi.error)
id = id + 1
+4 -1
View File
@@ -92,6 +92,8 @@ function multi:newProxy(list)
local sref = table.remove(data, 1)
local ret
print(_G[list[0]], func)
if sref then
ret = {_G[list[0]][func](_G[list[0]], multi.unpack(data))}
else
@@ -115,7 +117,7 @@ function multi:newProxy(list)
end)
end
end
end).OnError(multi.error)
end)
return self
else
local function copy(obj)
@@ -143,6 +145,7 @@ function multi:newProxy(list)
setmetatable(v[2],getmetatable(multi:newConnection()))
else
self[v] = thread:newFunction(function(self,...)
multi.print("Pushing: " .. v)
if self == me then
me.send:push({v, true, ...})
else