[][src]Crate rsevents

rsevents is an implementation of WIN32's auto- and manual-reset events for the rust world. Events are synchronization primitives (i.e. not implemented atop of mutexes) used to either create other synchronization primitives with or for implementing signalling between threads.

Events come in two different flavors: AutoResetEvent and ManualResetEvent. Internally, both are implemented with the unsafe [RawEvent] and use the parking_lot_core crate to take care of efficiently suspending (parking) threads while they wait for an event to become signalled.

An event is a synchronization primitive that is functionally the equivalent of an (optionally gated) waitable boolean that allows for synchronization between threads. Unlike mutexes and condition variables which are most often used to restrict access to a critical section, events are more appropriate for efficiently signalling remote threads or waiting on a remote thread to change state.



An AutoResetEvent is a gated event that is functionally equivalent to a "waitable boolean" and can be atomically waited upon and consumed to signal one and only one waiter at a time, thereby guaranteeing exclusive access to a critical section.


A ManualResetEvent is an event type best understood as a "waitable boolean" that efficiently synchronizes thread access to a shared state, allowing one or more threads to wait for a signal from one or more other threads, where the signal could have either occurred in the past or could come at any time in the future.



A representation of the state of an event, which can either be Set (i.e. signalled, ready) or Unset (i.e. not ready).