Modified changes
This commit is contained in:
parent
35a86a6cda
commit
bbc83acc0f
@ -84,12 +84,18 @@ multi:mainloop()
|
|||||||
Added
|
Added
|
||||||
---
|
---
|
||||||
- `thread.chain(...)` allows you to chain `thread.hold(FUNCTIONs)` together
|
- `thread.chain(...)` allows you to chain `thread.hold(FUNCTIONs)` together
|
||||||
```
|
```lua
|
||||||
while true do
|
while true do
|
||||||
thread.chain(hold_function_1, hold_function_2)
|
thread.chain(hold_function_1, hold_function_2)
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
If the first function returns true, it moves on to the next one
|
If the first function returns true, it moves on to the next one. if expanded it follows:
|
||||||
|
```lua
|
||||||
|
while true do
|
||||||
|
thread.hold(hold_function_1)
|
||||||
|
thread.hold(hold_function_2)
|
||||||
|
end
|
||||||
|
```
|
||||||
- Experimental option to multi settings: `findopt`. When set to `true` it will print out a message when certain pattern are used with this library. For example if an anonymous function is used in thread.hold() within a loop. The library will trigger a message alerting you that this isn't the most performant way to use thread.hold().
|
- Experimental option to multi settings: `findopt`. When set to `true` it will print out a message when certain pattern are used with this library. For example if an anonymous function is used in thread.hold() within a loop. The library will trigger a message alerting you that this isn't the most performant way to use thread.hold().
|
||||||
- `multi:newSystemThreadedConnection()`
|
- `multi:newSystemThreadedConnection()`
|
||||||
|
|
||||||
|
|||||||
26
init.lua
26
init.lua
@ -876,6 +876,32 @@ function multi:newTStep(start,reset,count,set)
|
|||||||
return c
|
return c
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local tasks = {}
|
||||||
|
local _tasks = 0
|
||||||
|
|
||||||
|
local function _task_handler()
|
||||||
|
tasks[#tasks + 1] = func
|
||||||
|
_tasks = _tasks + 1
|
||||||
|
end
|
||||||
|
|
||||||
|
function multi:newTask(func)
|
||||||
|
multi:newThread("Task Handler",function()
|
||||||
|
while true do
|
||||||
|
thread.hold(function()
|
||||||
|
return _tasks > 1
|
||||||
|
end)
|
||||||
|
for i=1,_tasks do
|
||||||
|
tasks[i]()
|
||||||
|
end
|
||||||
|
_tasks = 0
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
-- Re bind this method to use the one that doesn't init a thread!
|
||||||
|
multi.newTask = _task_handler
|
||||||
|
tasks[#tasks + 1] = func
|
||||||
|
_tasks = _tasks + 1
|
||||||
|
end
|
||||||
|
|
||||||
local scheduledjobs = {}
|
local scheduledjobs = {}
|
||||||
local sthread
|
local sthread
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user