holdWithin/For now accept conns
This commit is contained in:
parent
5ef2e0610c
commit
6039d6bf29
@ -64,6 +64,7 @@ Added:
|
|||||||
|
|
||||||
Fixed:
|
Fixed:
|
||||||
---
|
---
|
||||||
|
- thread.holdFor(n,func) and thread.holdWithin(n,func) now accept a connection object as the func argument
|
||||||
- Issue with threaded functions not handling nil properly from returns. This has been resolved and works as expected.
|
- Issue with threaded functions not handling nil properly from returns. This has been resolved and works as expected.
|
||||||
- Issue with system threaded job queues newFunction() not allowing nil returns! This has be addressed and is no longer an issue.
|
- Issue with system threaded job queues newFunction() not allowing nil returns! This has be addressed and is no longer an issue.
|
||||||
- Issue with hold like functions not being able to return `false`
|
- Issue with hold like functions not being able to return `false`
|
||||||
|
|||||||
@ -1195,6 +1195,17 @@ function multi.initThreads(justThreads)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
local function holdconn(n)
|
||||||
|
if type(ret[n])=="table" and ret[n].Type=='connector' then
|
||||||
|
local letsgo
|
||||||
|
ret[n](function(...) letsgo = {...} end)
|
||||||
|
ret[n] = function()
|
||||||
|
if letsgo then
|
||||||
|
return unpack(letsgo)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
local function helper(i)
|
local function helper(i)
|
||||||
if type(ret)=="table" then
|
if type(ret)=="table" then
|
||||||
if ret[1]=="_kill_" then
|
if ret[1]=="_kill_" then
|
||||||
@ -1215,20 +1226,13 @@ function multi.initThreads(justThreads)
|
|||||||
threads[i].__ready = false
|
threads[i].__ready = false
|
||||||
ret = nil
|
ret = nil
|
||||||
elseif ret[1]=="_hold_" then
|
elseif ret[1]=="_hold_" then
|
||||||
if type(ret[2])=="table" and ret[2].Type=='connector' then
|
holdconn(2)
|
||||||
local letsgo
|
|
||||||
ret[2](function(...) letsgo = {...} end)
|
|
||||||
ret[2] = function()
|
|
||||||
if letsgo then
|
|
||||||
return unpack(letsgo)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
threads[i].func = ret[2]
|
threads[i].func = ret[2]
|
||||||
threads[i].task = "hold"
|
threads[i].task = "hold"
|
||||||
threads[i].__ready = false
|
threads[i].__ready = false
|
||||||
ret = nil
|
ret = nil
|
||||||
elseif ret[1]=="_holdF_" then
|
elseif ret[1]=="_holdF_" then
|
||||||
|
holdconn(3)
|
||||||
threads[i].sec = ret[2]
|
threads[i].sec = ret[2]
|
||||||
threads[i].func = ret[3]
|
threads[i].func = ret[3]
|
||||||
threads[i].task = "holdF"
|
threads[i].task = "holdF"
|
||||||
@ -1236,6 +1240,7 @@ function multi.initThreads(justThreads)
|
|||||||
threads[i].__ready = false
|
threads[i].__ready = false
|
||||||
ret = nil
|
ret = nil
|
||||||
elseif ret[1]=="_holdW_" then
|
elseif ret[1]=="_holdW_" then
|
||||||
|
holdconn(3)
|
||||||
threads[i].count = ret[2]
|
threads[i].count = ret[2]
|
||||||
threads[i].pos = 0
|
threads[i].pos = 0
|
||||||
threads[i].func = ret[3]
|
threads[i].func = ret[3]
|
||||||
|
|||||||
13
test.lua
13
test.lua
@ -1,5 +1,14 @@
|
|||||||
package.path="?.lua;?/init.lua;?.lua;?/?/init.lua;"..package.path
|
package.path="?.lua;?/init.lua;?.lua;?/?/init.lua;"..package.path
|
||||||
multi, thread = require("multi"):init()
|
multi, thread = require("multi"):init()
|
||||||
|
conn = multi:newConnection()
|
||||||
|
func = thread:newFunction(function()
|
||||||
|
a,b,c = thread.holdFor(.5,conn)
|
||||||
|
print(a,b)
|
||||||
|
os.exit()
|
||||||
|
end)
|
||||||
|
func()
|
||||||
|
multi:setTimeout(function()
|
||||||
|
print("Test!")
|
||||||
|
conn:Fire(1,2,3)
|
||||||
|
end,1)
|
||||||
multi:lightloop()
|
multi:lightloop()
|
||||||
Loading…
x
Reference in New Issue
Block a user