diff --git a/integration/loveManager/extensions.lua b/integration/loveManager/extensions.lua index 69fe921..c5b1cc1 100644 --- a/integration/loveManager/extensions.lua +++ b/integration/loveManager/extensions.lua @@ -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() diff --git a/integration/loveManager/init.lua b/integration/loveManager/init.lua index 9bf5d2c..e12098a 100644 --- a/integration/loveManager/init.lua +++ b/integration/loveManager/init.lua @@ -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 diff --git a/integration/loveManager/threads.lua b/integration/loveManager/threads.lua index 2629dd5..354f46e 100644 --- a/integration/loveManager/threads.lua +++ b/integration/loveManager/threads.lua @@ -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)