I just mean blocking the main thread. In this model you would want to allocate an extra thread when starting Julia so that one thread can just be used for sleeping. (I agree this is not a great solution, but regular sleep
is so heavy that there’s no other option).
Really? Is this a recent change? (Does this mean I can dynamically create a thread for sleeping?)
Yeah it’s not a perfect solution. But on Linux, Libc.systemsleep
is much quicker than Base.sleep
(100x faster – lower end of 10 microseconds compared to 1 millisecond), which is enough of a win for me to want to use it.
It would be nice if there was waitany
version of wait(::Channel)
to react to any channel in a Vector{Channel}
being written to. Right now I have to loop through them individually and then sleep – that sleep is what’s bottlenecking my performance a bit. Although wait
isn’t great either, because my main thread is also doing other stuff in between polls. So a fast sleep
is really useful here.