expression
Notify currently registered waiters
Wake the current set of waiting notifications. A Notified future created before this call observes the broadcast even if not yet polled. A future created afterward cannot rely on that earlier broadcast. Use shared state with a notification when the condition matters. Tokio is an external dependency; see the proposed Cargo manifest. Expected stdout (not executed): both notified Common mistake: Assuming notify_waiters stores a notification for future subscribers.
Formal Syntax & Structure
rust syntaxrust
notify.notify_waiters()Working Example
Example Snippetrust
#[tokio::main(flavor = "current_thread")]async fn main() { let n = tokio::sync::Notify::new(); let a = n.notified(); let b = n.notified(); n.notify_waiters(); a.await; b.await; println!("both notified");}