Returning to the original topic, I still think it would be nice if Julia provided a safe way to
close()
/notify()
individual listeners for one-to-many events likeCondition
s andEvent
s. AFAICT, this can be done without making any changes to the existing code (see my earlier post)
The list_deletefirst
in your earlier post has a wide variety of data-races that make it very hard to reason about that code and almost impossible to write correctly or use. It does come up sometimes in Base and/or testing though, as means of recovering from some bad states (e.g. when errors happen that should not be possible), but it is used with there with the expectation that we are likely to crash anyways, so we do not care if it does so with a few extra errors along the way.
As you largely discovered, one reason that Julia doesn’t have wait_with_timeout is that it forces users to discover the cleaner design of pub-sub. It sounds like we should update the documentation to point people to Observables.jl, since your question is pretty common when coming from other languages that don’t have green-threads (and even from go, which does).
Returning to the original topic, I still think it would be nice if Julia provided a safe way to
close()
/notify()
individual listeners for one-to-many events likeCondition
s andEvent
s
Do you just mean notify(all=false)
or Event(autoreset=true)
? Either of those will alert only a single listener at a time. They are notably much harder to use than all=true
, but can be powerful tools when used exactly right (but otherwise your program hangs, which is generally unpleasant).