Added test cases for threading, fixed issues. Todo test love2d

This commit is contained in:
2023-04-25 00:13:47 -04:00
parent d2cfdfa8e8
commit 61b5ea9d14
7 changed files with 149 additions and 42 deletions
+7 -2
View File
@@ -114,7 +114,6 @@ function multi:newSystemThreadedJobQueue(n)
link = c.OnJobCompleted(function(jid,...)
if id==jid then
rets = {...}
link:Destroy()
end
end)
return thread.hold(function()
@@ -278,7 +277,13 @@ function multi:newSystemThreadedConnection(name)
self.links = {}
self.proxy_conn = multi:newConnection()
local mt = getmetatable(self.proxy_conn)
setmetatable(self, {__index = self.proxy_conn, __call = function(t,func) self.proxy_conn(func) end, __add = mt.__add})
local tempMT = {}
for i,v in pairs(mt) do
tempMT[i] = v
end
tempMT.__index = self.proxy_conn
tempMT.__call = function(t,func) self.proxy_conn(func) end
setmetatable(self, tempMT)
if self.CID == THREAD.getID() then return self end
thread:newThread("STC_CONN_MAN"..name,function()
local item
+12 -9
View File
@@ -95,10 +95,11 @@ function multi:newSystemThread(name, func, ...)
globals = globe,
priority = c.priority
},function(...)
require("multi"):init(multi_settings)
multi, thread = require("multi"):init(multi_settings)
require("multi.integration.lanesManager.extensions")
local has_error = true
return_linda:set("returns",{func(...)})
returns = {pcall(func, ...)}
return_linda:set("returns", returns)
has_error = false
end)(...)
count = count + 1
@@ -138,9 +139,15 @@ function multi.InitSystemThreadErrorHandler()
temp.statusconnector:Fire(unpack(({__StatusLinda:receive(nil, temp.Id)})[2]))
end
if status == "done" or temp.returns:get("returns") then
returns = ({temp.returns:receive(0, "returns")})[2]
livingThreads[temp.Id] = {false, temp.Name}
temp.alive = false
temp.OnDeath:Fire(unpack(({temp.returns:receive(0, "returns")})[2]))
if returns[1] == false then
temp.OnError:Fire(temp, returns[2])
else
table.remove(returns,1)
temp.OnDeath:Fire(unpack(returns))
end
GLOBAL["__THREADS__"] = livingThreads
table.remove(threads, i)
elseif status == "running" then
@@ -148,11 +155,7 @@ function multi.InitSystemThreadErrorHandler()
elseif status == "waiting" then
--
elseif status == "error" then
livingThreads[temp.Id] = {false, temp.Name}
temp.alive = false
temp.OnError:Fire(temp,unpack(temp.returns:receive(0,"returns") or {"Thread Killed!"}))
GLOBAL["__THREADS__"] = livingThreads
table.remove(threads, i)
-- The thread never really errors, we handle this through our linda object
elseif status == "cancelled" then
livingThreads[temp.Id] = {false, temp.Name}
temp.alive = false
@@ -168,7 +171,7 @@ function multi.InitSystemThreadErrorHandler()
end
end
end
end)
end).OnError(print)
end
multi.print("Integrated Lanes Threading!")