A simple and useful synchronization primitive in Python is threading.Event. It's basically a boolean flag that can be written to and read from an arbitrary number of threads, but it is also possible to block and wait with a timeout until the flag is set.
I am trying to find a similar concurrency primitive in sync Rust, but so far have not found anything straightforward. I would appreciate any recommendations.
to block on it, you first get a EventListener by calling listen() method.
EDIT: I should mention, although a Mutexcan be used as an event in special use cases, it's not what it is meant to. for one, at most one thread can be granted at a time; and also, "notifying" a blocking thread by "unlocking" a mutex is very cumbersome; and most importantly, Mutex is not meant to be held for long period.