Closed
Description
I was wondering if it would be possible to have a @sync block with a timeout like the below code does using a condition variable.
tic()
c = Condition()
cbfunc(aw, status) = begin
println("Timer triggered!")
notify(c, :ok)
stop_timer(aw)
end
t = TimeoutAsyncWork(cbfunc)
start_timer(t, 2.0, 0)
@async begin
@sync begin
@async begin
sleep (5.0)
end
end
notify(c, :ok)
stop_timer(t)
println("@async triggered!")
end
wait(c)
toc()
The above code works fine, it avoids polling too - I just thought it will be more useful if it can be provided by @sync itself and I couldn't think of an obvious way to do it.
Feel free to close this issue if it cannot be done, or extending @sync with a timeout is not recommended.
cc: @loladiro , @vtjnash , @JeffBezanson