sync: fix Notify example (#4212)

This commit is contained in:
Alice Ryhl
2021-11-02 16:22:30 +01:00
committed by GitHub
parent 09b770c5db
commit 1265d0c5dc
+4 -1
View File
@@ -57,13 +57,16 @@ type WaitList = LinkedList<Waiter, <Waiter as linked_list::Link>::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();
/// }
/// ```
///