diff --git a/multi/init.lua b/multi/init.lua index cd91633..f74e3bc 100644 --- a/multi/init.lua +++ b/multi/init.lua @@ -1,3 +1,4 @@ +print("Dev") --[[ MIT License @@ -1471,6 +1472,7 @@ co_status = { switch[task](ref,thd) cmds[r1](ref,r2,r3,r4,r5) if ret ~= CMD and _ ~= nil then -- The rework makes this necessary + print("Hello") co_status["dead"](thd,ref,task,i,th) end r1=nil r2=nil r3=nil r4=nil r5=nil @@ -1478,6 +1480,7 @@ co_status = { ["normal"] = function(thd,ref) end, ["running"] = function(thd,ref) end, ["dead"] = function(thd,ref,task,i,th) + if ref.__processed then return end if _ then ref.OnDeath:Fire(ret,r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11,r12,r13,r14,r15,r16) else @@ -1494,6 +1497,7 @@ co_status = { end end _=nil r1=nil r2=nil r3=nil r4=nil r5=nil + ref.__processed = true end, } handler = coroutine.wrap(function(self) diff --git a/multi/integration/lanesManager/init.lua b/multi/integration/lanesManager/init.lua index 316c24d..4bada5a 100644 --- a/multi/integration/lanesManager/init.lua +++ b/multi/integration/lanesManager/init.lua @@ -139,19 +139,19 @@ function multi.InitSystemThreadErrorHandler() elseif status == "error" then livingThreads[temp.Id] = {false, temp.Name} temp.alive = false - temp.OnError:Fire(temp,nil,unpack(temp.returns:receive(0,"returns") or {"Thread Killed!"})) + temp.OnError:Fire(temp,unpack(temp.returns:receive(0,"returns") or {"Thread Killed!"})) GLOBAL["__THREADS__"] = livingThreads table.remove(threads, i) elseif status == "cancelled" then livingThreads[temp.Id] = {false, temp.Name} temp.alive = false - temp.OnError:Fire(temp,nil,"thread_cancelled") + temp.OnError:Fire(temp,"thread_cancelled") GLOBAL["__THREADS__"] = livingThreads table.remove(threads, i) elseif status == "killed" then livingThreads[temp.Id] = {false, temp.Name} temp.alive = false - temp.OnError:Fire(temp,nil,"thread_killed") + temp.OnError:Fire(temp,"thread_killed") GLOBAL["__THREADS__"] = livingThreads table.remove(threads, i) end diff --git a/test.lua b/test.lua index 91d4732..fc484f9 100644 --- a/test.lua +++ b/test.lua @@ -1,18 +1,20 @@ -package.path = "./?/init.lua;"..package.path +package.path = "./?/init.lua;?.lua;lua5.4/share/lua/?/init.lua;lua5.4/share/lua/?.lua;"..package.path +package.cpath = "lua5.4/lib/lua/?/core.dll;"..package.cpath multi, thread = require("multi"):init{print=true} -GLOBAL, THREAD = require("multi.integration.threading"):init() +GLOBAL, THREAD = require("multi.integration.lanesManager"):init() -test = thread:newFunction(function() +test = THREAD:newFunction(function() + PNT() return 1,2 +end,true) +multi:newThread(function() + while true do + print("...") + thread.sleep(1) + end end) - -ref = test() -ref.OnError(function(...) - print("Got Error",...) -end) - -ref.OnReturn(function(...) - print("Got Returns",...) -end) +multi:newAlarm(.1):OnRing(function() os.exit() end) +print(test()) +print("Hi!") multi:mainloop() \ No newline at end of file