Events
Async manual-reset and auto-reset events for multi-use signaling.
This crate provides two families of event primitives:
- Manual-reset events (
ManualResetEvent,LocalManualResetEvent) — a gate that, once set, releases all current and future awaiters until explicitly reset. - Auto-reset events (
AutoResetEvent,LocalAutoResetEvent) — a token dispenser that releases exactly one awaiter perset()call.
Each family comes in a thread-safe variant (Send + Sync) and a single-threaded Local variant for improved efficiency when thread safety is not required.
Events are lightweight cloneable handles. All clones from the same family share the same underlying state.
Example
use ;
async
/// An [`AutoResetEvent`] releases exactly one awaiter per `set()` call.
/// If no one is waiting, the signal is remembered for the next waiter.
async
/// A [`ManualResetEvent`] acts as a gate: once set, all current and future
/// awaiters pass through until the event is explicitly reset.
async
See also
More details in the package documentation.
This is part of the Folo project that provides mechanisms for high-performance hardware-aware programming in Rust.