One of the unique characteristics of Rust (both the language and the community that has evolved around it) is a strong acknowledgement of multithreading, synchronization, and concurrency, as witnessed in the design of the core language (which acknowledges OS concepts of threads with sync
and send
) and the presence of various structures in the standard library aimed at simplifying development of correct, multithreaded code.
rsevents
is a new crate that should be immediately familiar to anyone that has done multithreaded programming under Windows: it exposes a synchronization primitive, namely, an event
for use where Mutex
– intended to exclusively marshall access to a variable or region of code – either does not convey the correct semantics or is not the right tool for the job. For those that didn’t come fleeing to rust from a Win32 background, in Windows an event
is the lowest-level kernel synchronization primitive, which can be thought of as a “waitable bool
” – it is either set
or reset
(on or off, true or false) and if it isn’t set, you can wait on it until it becomes set.