• Home
  • Raw
  • Download

Lines Matching full:notify

2 // due to the usage of `Notify` within the `rt` feature set.
27 /// `Notify` provides a basic mechanism to notify a single task of an event.
28 /// `Notify` itself does not carry any data. Instead, it is to be used to signal
31 /// A `Notify` can be thought of as a [`Semaphore`] starting with 0 permits. The
36 /// The synchronization details of `Notify` are similar to
37 /// [`thread::park`][park] and [`Thread::unpark`][unpark] from std. A [`Notify`]
55 /// use tokio::sync::Notify;
60 /// let notify = Arc::new(Notify::new());
61 /// let notify2 = notify.clone();
69 /// notify.notify_one();
79 /// `notify_one()` will store a permit in the `Notify`, which the following call
83 /// use tokio::sync::Notify;
90 /// notify: Notify,
98 /// // Notify the consumer a value is available
99 /// self.notify.notify_one();
112 /// self.notify.notified().await;
127 /// permit to the `Notify`.
134 /// to the `Notify`. This ensures that both futures are woken.
141 /// use tokio::sync::Notify;
148 /// notify_on_sent: Notify,
196 /// [`notified().await`]: Notify::notified()
197 /// [`notify_one()`]: Notify::notify_one()
201 pub struct Notify { struct
223 /// `Notify`, or it is exclusively owned by the enclosing `Waiter`. argument
306 /// List used in `Notify::notify_waiters`. It wraps a guarded linked list
307 /// and gates the access to it on `notify.waiters` mutex. It also empties
312 notify: &'a Notify, field
319 notify: &'a Notify, in new() argument
326 notify, in new()
331 /// requires an exclusive access to the main list in `Notify`.
348 let _lock_guard = self.notify.waiters.lock(); in drop()
358 /// Future returned from [`Notify::notified()`].
364 /// The `Notify` being received on.
365 notify: &'a Notify, field
420 impl Notify { implementation
421 /// Create a new `Notify`, initialized without a permit.
426 /// use tokio::sync::Notify;
428 /// let notify = Notify::new();
430 pub fn new() -> Notify { in new()
431 Notify { in new()
437 /// Create a new `Notify`, initialized without a permit.
442 /// use tokio::sync::Notify;
444 /// static NOTIFY: Notify = Notify::const_new();
447 pub const fn const_new() -> Notify { in const_new()
448 Notify { in const_new()
462 /// Each `Notify` value holds a single permit. If a permit is available from
475 /// [`notify_one()`]: Notify::notify_one
487 /// use tokio::sync::Notify;
492 /// let notify = Arc::new(Notify::new());
493 /// let notify2 = notify.clone();
501 /// notify.notify_one();
509 notify: self, in notified()
519 /// permit is stored in this `Notify` value and the **next** call to
523 /// At most one permit may be stored by `Notify`. Many sequential calls to
528 /// [`notified().await`]: Notify::notified()
533 /// use tokio::sync::Notify;
538 /// let notify = Arc::new(Notify::new());
539 /// let notify2 = notify.clone();
547 /// notify.notify_one();
551 #[cfg_attr(docsrs, doc(alias = "notify"))]
573 // There are waiters, the lock must be acquired to notify. in notify_one()
590 /// `notified().await`. The purpose of this method is to notify all
597 /// use tokio::sync::Notify;
602 /// let notify = Arc::new(Notify::new());
603 /// let notify2 = notify.clone();
605 /// let notified1 = notify.notified();
606 /// let notified2 = notify.notified();
694 impl Default for Notify { implementation
695 fn default() -> Notify { in default()
696 Notify::new() in default()
700 impl UnwindSafe for Notify {} implementation
701 impl RefUnwindSafe for Notify {} implementation
772 /// `Notify` was holding a permit from a previous call to `notify_one`.
776 /// `Notify`, or by a call to `notify_one` or `notify_waiters` that
793 /// permit to the `Notify`.
800 /// to the `Notify`. This ensures that both futures are woken.
803 /// use tokio::sync::Notify;
810 /// notify_on_sent: Notify,
856 /// [`notify_one`]: Notify::notify_one()
857 /// [`notify_waiters`]: Notify::notify_waiters()
864 fn project(self: Pin<&mut Self>) -> (&Notify, &mut State, &usize, &Waiter) { in project() argument
866 // Safety: `notify`, `state` and `notify_waiters_calls` are `Unpin`. in project()
868 is_unpin::<&Notify>(); in project()
874 me.notify, in project()
885 let (notify, state, notify_waiters_calls, waiter) = self.project(); in poll_notified()
890 let curr = notify.state.load(SeqCst); in poll_notified()
893 let res = notify.state.compare_exchange( in poll_notified()
912 let mut waiters = notify.waiters.lock(); in poll_notified()
915 let mut curr = notify.state.load(SeqCst); in poll_notified()
929 let res = notify.state.compare_exchange( in poll_notified()
946 let res = notify.state.compare_exchange( in poll_notified()
1009 // list (guarded by `notify.waiters`). In order to access the waker in poll_notified()
1013 let mut waiters = notify.waiters.lock(); in poll_notified()
1034 let curr = notify.state.load(SeqCst); in poll_notified()
1111 let (notify, state, _, waiter) = unsafe { Pin::new_unchecked(self).project() }; in drop()
1117 let mut waiters = notify.waiters.lock(); in drop()
1118 let mut notify_state = notify.state.load(SeqCst); in drop()
1133 notify.state.store(notify_state, SeqCst); in drop()
1140 if let Some(waker) = notify_locked(&mut waiters, &notify.state, notify_state) { in drop()