Working on 16.0.0 #53
@ -84,6 +84,7 @@ Allows the user to have multi auto set priorities (Requires chronos). Also adds
|
|||||||
|
|
||||||
Added
|
Added
|
||||||
---
|
---
|
||||||
|
- thread.defer(func) -- When using a co-routine thread or co-routine threaded function, defer will call it's function at the end of the the threads life through normal execution or an error. In the case of a function, when the function returns or errors.
|
||||||
- multi:setTaskDelay(delay), Tasks which are now tied to a processor can have an optional delay between the execution between each task. Useful perhaps for rate limiting. Without a delay all grouped tasks will be handled in one step.
|
- multi:setTaskDelay(delay), Tasks which are now tied to a processor can have an optional delay between the execution between each task. Useful perhaps for rate limiting. Without a delay all grouped tasks will be handled in one step.
|
||||||
- processor's now have a boost function which causes it to run its processes the number of times specified in the `boost(count)` function
|
- processor's now have a boost function which causes it to run its processes the number of times specified in the `boost(count)` function
|
||||||
- thread.hold will now use a custom hold method for objects with a `Hold` method. This is called like `obj:Hold(opt)`. The only argument passed is the optional options table that thread.hold can pass. There is an exception for connection objects. While they do contain a Hold method, the Hold method isn't used and is there for proxy objects, though they can be used in non proxy/thread situations. Hold returns all the arguments that the connection object was fired with.
|
- thread.hold will now use a custom hold method for objects with a `Hold` method. This is called like `obj:Hold(opt)`. The only argument passed is the optional options table that thread.hold can pass. There is an exception for connection objects. While they do contain a Hold method, the Hold method isn't used and is there for proxy objects, though they can be used in non proxy/thread situations. Hold returns all the arguments that the connection object was fired with.
|
||||||
|
|||||||
8
init.lua
8
init.lua
@ -1250,6 +1250,14 @@ function thread.request(t,cmd,...)
|
|||||||
thread.requests[t.thread] = {cmd, multi.pack(...)}
|
thread.requests[t.thread] = {cmd, multi.pack(...)}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function thread.defer(func)
|
||||||
|
local th = thread.getRunningThread()
|
||||||
|
local conn = (th.OnError + th.OnDeath)
|
||||||
|
conn(function()
|
||||||
|
func(th)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
function thread.getRunningThread()
|
function thread.getRunningThread()
|
||||||
local threads = globalThreads
|
local threads = globalThreads
|
||||||
local t = coroutine.running()
|
local t = coroutine.running()
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
package.path = "../?/init.lua;../?.lua;"..package.path
|
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")
|
-- require("multi.integration.priorityManager")
|
||||||
|
|
||||||
-- multi.debugging.OnObjectCreated(function(obj, process)
|
-- 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:setTaskDelay(.05)
|
||||||
multi:newTask(function()
|
multi:newTask(function()
|
||||||
for i = 1, 100 do
|
for i = 1, 10 do
|
||||||
multi:newTask(function()
|
multi:newTask(function()
|
||||||
print("Task "..i)
|
print("Task "..i)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
multi:newTask(function()
|
|
||||||
multi:Stop()
|
|
||||||
end)
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
local conn = multi:newConnection()
|
local conn = multi:newConnection()
|
||||||
@ -125,6 +122,17 @@ conn:Fire()
|
|||||||
|
|
||||||
print(#conn)
|
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()
|
multi:mainloop()
|
||||||
|
|
||||||
-- local conn1, conn2, conn3 = multi:newConnection(nil,nil,true), multi:newConnection(), multi:newConnection()
|
-- local conn1, conn2, conn3 = multi:newConnection(nil,nil,true), multi:newConnection(), multi:newConnection()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user