Fixed love2d to succeed with tests

This commit is contained in:
Ryan Ward 2023-04-25 21:31:36 -04:00
parent 61b5ea9d14
commit 45b51c15c7
3 changed files with 36 additions and 3 deletions

View File

@ -130,7 +130,6 @@ function multi:newSystemThreadedJobQueue(n)
link = c.OnJobCompleted(function(jid,...)
if id==jid then
rets = {...}
link:Destroy()
end
end)
return thread.hold(function()

View File

@ -40,6 +40,12 @@ math.random()
math.random()
stab = THREAD.createStaticTable(__THREADNAME__ .. __THREADID__)
GLOBAL = THREAD.getGlobal()
if GLOBAL["__env"] then
local env = THREAD.unpackENV(GLOBAL["__env"])
for i,v in pairs(env) do
_G[i] = v
end
end
multi, thread = require("multi").init()
multi.integration={}
multi.integration.GLOBAL = GLOBAL

View File

@ -139,8 +139,36 @@ function threads.getGlobal()
)
end
function THREAD.setENV(env)
(threads.getGlobal())["__env"] = env
function threads.packENV(env)
local e = {}
for i,v in pairs(env) do
if type(v) == "function" then
e["$f"..i] = string.dump(v)
elseif type(v) == "table" then
e["$t"..i] = threads.packENV(v)
else
e[i] = v
end
end
return e
end
function threads.unpackENV(env)
local e = {}
for i,v in pairs(env) do
if type(i) == "string" and i:sub(1,2) == "$f" then
e[i:sub(3,-1)] = loadstring(v)
elseif type(i) == "string" and i:sub(1,2) == "$t" then
e[i:sub(3,-1)] = threads.unpackENV(v)
else
e[i] = v
end
end
return e
end
function threads.setENV(env)
(threads.getGlobal())["__env"] = threads.packENV(env)
end
function threads.createTable(n)