lanes uses a threaded function like waitfor function
This commit is contained in:
parent
b4c3708f50
commit
946217310f
4
init.lua
4
init.lua
@ -1226,7 +1226,9 @@ end
|
|||||||
function multi.hold(func,opt)
|
function multi.hold(func,opt)
|
||||||
if thread.isThread() then return thread.hold(func, opt) end
|
if thread.isThread() then return thread.hold(func, opt) end
|
||||||
local proc = multi.getCurrentTask()
|
local proc = multi.getCurrentTask()
|
||||||
|
if proc then
|
||||||
proc:Pause()
|
proc:Pause()
|
||||||
|
end
|
||||||
local rets
|
local rets
|
||||||
thread:newThread("Hold_func",function()
|
thread:newThread("Hold_func",function()
|
||||||
rets = {thread.hold(func,opt)}
|
rets = {thread.hold(func,opt)}
|
||||||
@ -1234,7 +1236,9 @@ function multi.hold(func,opt)
|
|||||||
while rets == nil do
|
while rets == nil do
|
||||||
multi:uManager()
|
multi:uManager()
|
||||||
end
|
end
|
||||||
|
if proc then
|
||||||
proc:Resume()
|
proc:Resume()
|
||||||
|
end
|
||||||
return multi.unpack(rets)
|
return multi.unpack(rets)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -48,14 +48,12 @@ local function INIT(__GlobalLinda, __SleepingLinda, __StatusLinda, __Console)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function THREAD.waitFor(name)
|
function THREAD.waitFor(name)
|
||||||
local function wait()
|
local multi, thread = require("multi"):init()
|
||||||
|
return multi.hold(function()
|
||||||
math.randomseed(os.time())
|
math.randomseed(os.time())
|
||||||
__SleepingLinda:receive(.001, "__non_existing_variable")
|
__SleepingLinda:receive(.001, "__non_existing_variable")
|
||||||
end
|
|
||||||
repeat
|
|
||||||
wait()
|
|
||||||
until __GlobalLinda:get(name)
|
|
||||||
return __GlobalLinda:get(name)
|
return __GlobalLinda:get(name)
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
function THREAD.getCores()
|
function THREAD.getCores()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user