mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-23 00:00:10 +02:00
sync: fix Notify example (#4212)
This commit is contained in:
@@ -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();
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user