From 1265d0c5dcf0f0c46430ef9f26710aac952c545e Mon Sep 17 00:00:00 2001 From: Alice Ryhl Date: Tue, 2 Nov 2021 16:22:30 +0100 Subject: [PATCH] sync: fix Notify example (#4212) --- tokio/src/sync/notify.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tokio/src/sync/notify.rs b/tokio/src/sync/notify.rs index 417f87b41..c93ce3bd4 100644 --- a/tokio/src/sync/notify.rs +++ b/tokio/src/sync/notify.rs @@ -57,13 +57,16 @@ type WaitList = LinkedList::Target>; /// let notify = Arc::new(Notify::new()); /// let notify2 = notify.clone(); /// -/// tokio::spawn(async move { +/// let handle = tokio::spawn(async move { /// notify2.notified().await; /// println!("received notification"); /// }); /// /// println!("sending notification"); /// notify.notify_one(); +/// +/// // Wait for task to receive notification. +/// handle.await.unwrap(); /// } /// ``` ///