expression

Single notification without a payload

Notify can wake a waiting task or store one notification for a later waiter. It carries no message. Repeated notifications without waiters do not create an arbitrary queue of pending events. Tokio is an external dependency; see the proposed Cargo manifest. Expected stdout (not executed): notified Common mistake: Treating Notify as a counting semaphore or a message queue.

Formal Syntax & Structure

rust syntaxrust
notify.notify_one(); notify.notified().await

Working Example

Example Snippetrust
#[tokio::main(flavor = "current_thread")]async fn main() {    let n = tokio::sync::Notify::new();    n.notify_one();    n.notified().await;    println!("notified");}
Rust Reference