mirror of
https://github.com/rayaman/multi.git
synced 2026-09-05 07:27:35 -04:00
Added thread.defer(func)
This commit is contained in:
+13
-5
@@ -1,5 +1,5 @@
|
||||
package.path = "../?/init.lua;../?.lua;"..package.path
|
||||
multi, thread = require("multi"):init{print=true,warn=true,error=true,debugging=true}
|
||||
multi, thread = require("multi"):init{print=true,warn=true,debugging=true}
|
||||
-- require("multi.integration.priorityManager")
|
||||
|
||||
-- multi.debugging.OnObjectCreated(function(obj, process)
|
||||
@@ -101,14 +101,11 @@ multi, thread = require("multi"):init{print=true,warn=true,error=true,debugging=
|
||||
|
||||
multi:setTaskDelay(.05)
|
||||
multi:newTask(function()
|
||||
for i = 1, 100 do
|
||||
for i = 1, 10 do
|
||||
multi:newTask(function()
|
||||
print("Task "..i)
|
||||
end)
|
||||
end
|
||||
multi:newTask(function()
|
||||
multi:Stop()
|
||||
end)
|
||||
end)
|
||||
|
||||
local conn = multi:newConnection()
|
||||
@@ -125,6 +122,17 @@ conn:Fire()
|
||||
|
||||
print(#conn)
|
||||
|
||||
thread:newThread("Test thread", function()
|
||||
print("Starting thread!")
|
||||
thread.defer(function() -- Runs when the thread finishes execution
|
||||
print("Clean up time!")
|
||||
end)
|
||||
--[[
|
||||
Do lot's of stuff
|
||||
]]
|
||||
thread.sleep(3)
|
||||
end)
|
||||
|
||||
multi:mainloop()
|
||||
|
||||
-- local conn1, conn2, conn3 = multi:newConnection(nil,nil,true), multi:newConnection(), multi:newConnection()
|
||||
|
||||
Reference in New Issue
Block a user