lanes uses a threaded function like waitfor function

This commit is contained in:
Ryan Ward 2024-02-24 23:23:35 -05:00
parent b4c3708f50
commit 946217310f
2 changed files with 10 additions and 8 deletions

View File

@ -1226,7 +1226,9 @@ end
function multi.hold(func,opt)
if thread.isThread() then return thread.hold(func, opt) end
local proc = multi.getCurrentTask()
proc:Pause()
if proc then
proc:Pause()
end
local rets
thread:newThread("Hold_func",function()
rets = {thread.hold(func,opt)}
@ -1234,7 +1236,9 @@ function multi.hold(func,opt)
while rets == nil do
multi:uManager()
end
proc:Resume()
if proc then
proc:Resume()
end
return multi.unpack(rets)
end

View File

@ -48,14 +48,12 @@ local function INIT(__GlobalLinda, __SleepingLinda, __StatusLinda, __Console)
end
function THREAD.waitFor(name)
local function wait()
local multi, thread = require("multi"):init()
return multi.hold(function()
math.randomseed(os.time())
__SleepingLinda:receive(.001, "__non_existing_variable")
end
repeat
wait()
until __GlobalLinda:get(name)
return __GlobalLinda:get(name)
return __GlobalLinda:get(name)
end)
end
function THREAD.getCores()