id
stringlengths
22
133
text
stringlengths
40
40.2k
arch
stringclasses
1 value
syntax
stringclasses
1 value
kind
stringclasses
4 values
repo
stringclasses
27 values
path
stringlengths
5
116
license
stringclasses
6 values
commit
stringlengths
40
40
source_host
stringclasses
1 value
category
stringclasses
16 values
source_url
stringlengths
85
196
line_start
int64
1
4.28k
line_end
int64
4
4.31k
tokio-rs/tokio:tokio/src/sync/notify.rs:28
// Load the state with the lock held. let curr = notify.state.load(SeqCst); if get_num_notify_waiters_calls(curr) != *notify_waiters_calls { // Before we add a waiter to the list we check if these numbers are // different while hol...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
9e00b266e08d263c497dc9de57d9acbc049ae69b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9e00b266e08d263c497dc9de57d9acbc049ae69b/tokio/src/sync/notify.rs
1,081
1,140
tokio-rs/tokio:tokio/src/sync/notify.rs:29
return Poll::Pending; } // Explicit drop of the lock to indicate the scope that the // lock is held. Because holding the lock is required to // ensure safe access to fields not held within the lock, it // is helpful to ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
9e00b266e08d263c497dc9de57d9acbc049ae69b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9e00b266e08d263c497dc9de57d9acbc049ae69b/tokio/src/sync/notify.rs
1,121
1,180
tokio-rs/tokio:tokio/src/sync/notify.rs:6
pub struct Notify { // `state` uses 2 bits to store one of `EMPTY`, // `WAITING` or `NOTIFIED`. The rest of the bits // are used to store the number of times `notify_waiters` // was called. // // Throughout the code there are two assumptions: // - state can be transitioned *from* `WAITING` o...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
6871084629ad95c37c7136d865890ab2e371ea12
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/sync/notify.rs
201
260
tokio-rs/tokio:tokio/src/sync/notify.rs:7
notification: AtomicNotification::none(), _p: PhantomPinned, } } } generate_addr_of_methods! { impl<> Waiter { unsafe fn addr_of_pointers(self: NonNull<Self>) -> NonNull<linked_list::Pointers<Waiter>> { &self.pointers } } } // No notification. const NOTIFICA...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
6871084629ad95c37c7136d865890ab2e371ea12
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/sync/notify.rs
241
300
tokio-rs/tokio:tokio/src/sync/notify.rs:8
fn load(&self, ordering: Ordering) -> Option<Notification> { match self.0.load(ordering) { NOTIFICATION_NONE => None, NOTIFICATION_ONE => Some(Notification::One), NOTIFICATION_ALL => Some(Notification::All), _ => unreachable!(), } } /// Clears the...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
6871084629ad95c37c7136d865890ab2e371ea12
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/sync/notify.rs
281
340
tokio-rs/tokio:tokio/src/sync/notify.rs:9
let guard_ptr = NonNull::from(guard.get_ref()); let list = unguarded_list.into_guarded(guard_ptr); NotifyWaitersList { list, is_empty: false, notify, } } /// Removes the last element from the guarded list. Modifying this list /// requires an exclu...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
6871084629ad95c37c7136d865890ab2e371ea12
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/sync/notify.rs
321
380
tokio-rs/tokio:tokio/src/sync/notify.rs:10
/// will immediately return `Poll::Ready`. #[derive(Debug)] pub struct Notified<'a> { /// The `Notify` being received on. notify: &'a Notify, /// The current state of the receiving process. state: State, /// Number of calls to `notify_waiters` at the time of creation. notify_waiters_calls: usi...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
6871084629ad95c37c7136d865890ab2e371ea12
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/sync/notify.rs
361
420
tokio-rs/tokio:tokio/src/sync/notify.rs:11
(data & NOTIFY_WAITERS_CALLS_MASK) | (state & STATE_MASK) } fn get_state(data: usize) -> usize { data & STATE_MASK } fn get_num_notify_waiters_calls(data: usize) -> usize { (data & NOTIFY_WAITERS_CALLS_MASK) >> NOTIFY_WAITERS_SHIFT } fn inc_num_notify_waiters_calls(data: usize) -> usize { data + (1 << NO...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
6871084629ad95c37c7136d865890ab2e371ea12
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/sync/notify.rs
401
460
tokio-rs/tokio:tokio/src/sync/notify.rs:14
} } /// Notifies a waiting task. /// /// If a task is currently waiting, that task is notified. Otherwise, a /// permit is stored in this `Notify` value and the **next** call to /// [`notified().await`] will complete immediately consuming the permit made /// available by this call to `notif...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
6871084629ad95c37c7136d865890ab2e371ea12
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/sync/notify.rs
521
580
tokio-rs/tokio:tokio/src/sync/notify.rs:15
// Load the current state let mut curr = self.state.load(SeqCst); // If the state is `EMPTY`, transition to `NOTIFIED` and return. while let EMPTY | NOTIFIED = get_state(curr) { // The compare-exchange from `NOTIFIED` -> `NOTIFIED` is intended. A // happens-before synchr...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
6871084629ad95c37c7136d865890ab2e371ea12
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/sync/notify.rs
561
620
tokio-rs/tokio:tokio/src/sync/notify.rs:16
/// /// # Examples /// /// ``` /// use tokio::sync::Notify; /// use std::sync::Arc; /// /// #[tokio::main] /// async fn main() { /// let notify = Arc::new(Notify::new()); /// let notify2 = notify.clone(); /// /// let notified1 = notify.notified(); /// ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
6871084629ad95c37c7136d865890ab2e371ea12
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/sync/notify.rs
601
660
tokio-rs/tokio:tokio/src/sync/notify.rs:17
// and transition to empty. let new_state = set_state(inc_num_notify_waiters_calls(curr), EMPTY); self.state.store(new_state, SeqCst); // It is critical for `GuardedLinkedList` safety that the guard node is // pinned in memory and is not dropped until the guarded list is dropped. ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
6871084629ad95c37c7136d865890ab2e371ea12
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/sync/notify.rs
641
700
tokio-rs/tokio:tokio/src/sync/notify.rs:18
} } // Release the lock before notifying. drop(waiters); // One of the wakers may panic, but the remaining waiters will still // be unlinked from the list in `NotifyWaitersList` destructor. wakers.wake_all(); // Acquire the lock agai...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
6871084629ad95c37c7136d865890ab2e371ea12
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/sync/notify.rs
681
740
tokio-rs/tokio:tokio/src/sync/notify.rs:19
state.store(set_state(actual, NOTIFIED), SeqCst); None } } } WAITING => { // At this point, it is guaranteed that the state will not // concurrently change as holding the lock is required to // transition **out** of `WAI...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
6871084629ad95c37c7136d865890ab2e371ea12
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/sync/notify.rs
721
780
tokio-rs/tokio:tokio/src/sync/notify.rs:22
/// future.as_mut().enable(); /// /// if let Some(msg) = self.try_recv() { /// return msg; /// } /// /// // Wait for a call to `notify_one`. /// // /// // This uses `.as_mut()` to avoid consuming the ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
6871084629ad95c37c7136d865890ab2e371ea12
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/sync/notify.rs
841
900
tokio-rs/tokio:tokio/src/sync/notify.rs:23
&me.notify_waiters_calls, &me.waiter, ) } } fn poll_notified(self: Pin<&mut Self>, waker: Option<&Waker>) -> Poll<()> { let (notify, state, notify_waiters_calls, waiter) = self.project(); 'outer_loop: loop { match *state { State::...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
6871084629ad95c37c7136d865890ab2e371ea12
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/sync/notify.rs
881
940
tokio-rs/tokio:tokio/src/sync/notify.rs:24
// was created, then we are done if get_num_notify_waiters_calls(curr) != *notify_waiters_calls { *state = State::Done; continue 'outer_loop; } // Transition the state to WAITING. loop { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
6871084629ad95c37c7136d865890ab2e371ea12
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/sync/notify.rs
921
980
tokio-rs/tokio:tokio/src/sync/notify.rs:25
} Err(actual) => { assert_eq!(get_state(actual), EMPTY); curr = actual; } } } _ ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
6871084629ad95c37c7136d865890ab2e371ea12
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/sync/notify.rs
961
1,020
tokio-rs/tokio:tokio/src/sync/notify.rs:26
if waiter.notification.load(Acquire).is_some() { // Safety: waiter is already unlinked and will not be shared again, // so we have an exclusive access to `waker`. drop(unsafe { waiter.waker.with_mut(|waker| (*waker).take()) }); ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
6871084629ad95c37c7136d865890ab2e371ea12
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/sync/notify.rs
1,001
1,060
tokio-rs/tokio:tokio/src/sync/notify.rs:27
// different while holding the lock. If these numbers are different now, // it means that there is a call to `notify_waiters` in progress and this // waiter must be contained by a guarded list used in `notify_waiters`. // We can treat the waiter as...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
6871084629ad95c37c7136d865890ab2e371ea12
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/sync/notify.rs
1,041
1,100
tokio-rs/tokio:tokio/src/sync/notify.rs:28
// is helpful to visualize the scope of the critical // section. drop(waiters); // Drop the old waker after releasing the lock. drop(old_waker); } State::Done => { #[cfg(tokio_taskdump)] ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
6871084629ad95c37c7136d865890ab2e371ea12
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/sync/notify.rs
1,081
1,140
tokio-rs/tokio:tokio/src/sync/notify.rs:29
// We hold the lock, so this field is not concurrently accessed by // `notify_*` functions and we can use the relaxed ordering. let notification = waiter.notification.load(Relaxed); // remove the entry from the list (if not already removed) // // Safety: we h...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
6871084629ad95c37c7136d865890ab2e371ea12
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/sync/notify.rs
1,121
1,170
tokio-rs/tokio:tokio/src/sync/notify.rs:30
unsafe fn from_raw(ptr: NonNull<Waiter>) -> NonNull<Waiter> { ptr } unsafe fn pointers(target: NonNull<Waiter>) -> NonNull<linked_list::Pointers<Waiter>> { Waiter::addr_of_pointers(target) } } fn is_unpin<T: Unpin>() {}
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
6871084629ad95c37c7136d865890ab2e371ea12
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/sync/notify.rs
1,161
1,170
tokio-rs/tokio:tokio/src/sync/notify.rs:18
} } // Release the lock before notifying. drop(waiters); // One of the wakers may panic, but the remaining waiters will still // be unlinked from the list in `NotifyWaitersList` destructor. wakers.wake_all(); // Acquire the lock agai...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
707fb4d0df72d7ee6a4f4b5a675f84cd1863bc94
github
async-runtime
https://github.com/tokio-rs/tokio/blob/707fb4d0df72d7ee6a4f4b5a675f84cd1863bc94/tokio/src/sync/notify.rs
681
740
tokio-rs/tokio:tokio/src/sync/notify.rs:19
assert!(actual_state == EMPTY || actual_state == NOTIFIED); state.store(set_state(actual, NOTIFIED), SeqCst); return None; } } } WAITING => { // At this point, it is guaranteed that the state will...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
707fb4d0df72d7ee6a4f4b5a675f84cd1863bc94
github
async-runtime
https://github.com/tokio-rs/tokio/blob/707fb4d0df72d7ee6a4f4b5a675f84cd1863bc94/tokio/src/sync/notify.rs
721
780
tokio-rs/tokio:tokio/src/sync/notify.rs:22
/// loop { /// // Make sure that no wakeup is lost if we get /// // `None` from `try_recv`. /// future.as_mut().enable(); /// /// if let Some(msg) = self.try_recv() { /// return msg; /// } /// /// ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
707fb4d0df72d7ee6a4f4b5a675f84cd1863bc94
github
async-runtime
https://github.com/tokio-rs/tokio/blob/707fb4d0df72d7ee6a4f4b5a675f84cd1863bc94/tokio/src/sync/notify.rs
841
900
tokio-rs/tokio:tokio/src/sync/notify.rs:23
( me.notify, &mut me.state, &me.notify_waiters_calls, &me.waiter, ) } } fn poll_notified(self: Pin<&mut Self>, waker: Option<&Waker>) -> Poll<()> { let (notify, state, notify_waiters_calls, waiter) = self.project(); ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
707fb4d0df72d7ee6a4f4b5a675f84cd1863bc94
github
async-runtime
https://github.com/tokio-rs/tokio/blob/707fb4d0df72d7ee6a4f4b5a675f84cd1863bc94/tokio/src/sync/notify.rs
881
940
tokio-rs/tokio:tokio/src/sync/notify.rs:24
let mut curr = notify.state.load(SeqCst); // if notify_waiters has been called after the future // was created, then we are done if get_num_notify_waiters_calls(curr) != *notify_waiters_calls { *state = State::Done; ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
707fb4d0df72d7ee6a4f4b5a675f84cd1863bc94
github
async-runtime
https://github.com/tokio-rs/tokio/blob/707fb4d0df72d7ee6a4f4b5a675f84cd1863bc94/tokio/src/sync/notify.rs
921
980
tokio-rs/tokio:tokio/src/sync/notify.rs:25
// Acquired the notification *state = State::Done; continue 'outer_loop; } Err(actual) => { assert_eq!(get_state(actual), EMPTY)...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
707fb4d0df72d7ee6a4f4b5a675f84cd1863bc94
github
async-runtime
https://github.com/tokio-rs/tokio/blob/707fb4d0df72d7ee6a4f4b5a675f84cd1863bc94/tokio/src/sync/notify.rs
961
1,020
tokio-rs/tokio:tokio/src/sync/notify.rs:26
ready!(crate::trace::trace_leaf(&mut ctx)); } if waiter.notification.load(Acquire).is_some() { // Safety: waiter is already unlinked and will not be shared again, // so we have an exclusive access to `waker`. ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
707fb4d0df72d7ee6a4f4b5a675f84cd1863bc94
github
async-runtime
https://github.com/tokio-rs/tokio/blob/707fb4d0df72d7ee6a4f4b5a675f84cd1863bc94/tokio/src/sync/notify.rs
1,001
1,060
tokio-rs/tokio:tokio/src/sync/notify.rs:27
if get_num_notify_waiters_calls(curr) != *notify_waiters_calls { // Before we add a waiter to the list we check if these numbers are // different while holding the lock. If these numbers are different now, // it means that there is a call to `notif...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
707fb4d0df72d7ee6a4f4b5a675f84cd1863bc94
github
async-runtime
https://github.com/tokio-rs/tokio/blob/707fb4d0df72d7ee6a4f4b5a675f84cd1863bc94/tokio/src/sync/notify.rs
1,041
1,100
tokio-rs/tokio:tokio/src/sync/notify.rs:28
// Explicit drop of the lock to indicate the scope that the // lock is held. Because holding the lock is required to // ensure safe access to fields not held within the lock, it // is helpful to visualize the scope of the critical // sectio...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
707fb4d0df72d7ee6a4f4b5a675f84cd1863bc94
github
async-runtime
https://github.com/tokio-rs/tokio/blob/707fb4d0df72d7ee6a4f4b5a675f84cd1863bc94/tokio/src/sync/notify.rs
1,081
1,140
tokio-rs/tokio:tokio/src/sync/notify.rs:29
let mut waiters = notify.waiters.lock(); let mut notify_state = notify.state.load(SeqCst); // We hold the lock, so this field is not concurrently accessed by // `notify_*` functions and we can use the relaxed ordering. let notification = waiter.notification.load(Relaxed)...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
707fb4d0df72d7ee6a4f4b5a675f84cd1863bc94
github
async-runtime
https://github.com/tokio-rs/tokio/blob/707fb4d0df72d7ee6a4f4b5a675f84cd1863bc94/tokio/src/sync/notify.rs
1,121
1,173
tokio-rs/tokio:tokio/src/sync/notify.rs:30
*handle } unsafe fn from_raw(ptr: NonNull<Waiter>) -> NonNull<Waiter> { ptr } unsafe fn pointers(target: NonNull<Waiter>) -> NonNull<linked_list::Pointers<Waiter>> { Waiter::addr_of_pointers(target) } } fn is_unpin<T: Unpin>() {}
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
707fb4d0df72d7ee6a4f4b5a675f84cd1863bc94
github
async-runtime
https://github.com/tokio-rs/tokio/blob/707fb4d0df72d7ee6a4f4b5a675f84cd1863bc94/tokio/src/sync/notify.rs
1,161
1,173
tokio-rs/tokio:tokio/src/sync/notify.rs:22
/// loop { /// // Make sure that no wakeup is lost if we get /// // `None` from `try_recv`. /// future.as_mut().enable(); /// /// if let Some(msg) = self.try_recv() { /// return msg; /// } /// /// ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
d247e7f5df4bd861287467ecc5f827538bee4d63
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d247e7f5df4bd861287467ecc5f827538bee4d63/tokio/src/sync/notify.rs
841
900
tokio-rs/tokio:tokio/src/sync/notify.rs:23
( me.notify, &mut me.state, &me.notify_waiters_calls, &me.waiter, ) } } fn poll_notified(self: Pin<&mut Self>, waker: Option<&Waker>) -> Poll<()> { use State::*; let (notify, state, notify_waiters_calls, waiter...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
d247e7f5df4bd861287467ecc5f827538bee4d63
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d247e7f5df4bd861287467ecc5f827538bee4d63/tokio/src/sync/notify.rs
881
940
tokio-rs/tokio:tokio/src/sync/notify.rs:24
// Reload the state with the lock held let mut curr = notify.state.load(SeqCst); // if notify_waiters has been called after the future // was created, then we are done if get_num_notify_waiters_calls(curr) != *notify_waiters_calls { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
d247e7f5df4bd861287467ecc5f827538bee4d63
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d247e7f5df4bd861287467ecc5f827538bee4d63/tokio/src/sync/notify.rs
921
980
tokio-rs/tokio:tokio/src/sync/notify.rs:25
match res { Ok(_) => { // Acquired the notification *state = Done; continue 'outer_loop; } E...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
d247e7f5df4bd861287467ecc5f827538bee4d63
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d247e7f5df4bd861287467ecc5f827538bee4d63/tokio/src/sync/notify.rs
961
1,020
tokio-rs/tokio:tokio/src/sync/notify.rs:26
if let Some(waker) = waker { let mut ctx = Context::from_waker(waker); ready!(crate::trace::trace_leaf(&mut ctx)); } if waiter.notification.load(Acquire).is_some() { // Safety: waiter is already unlinked and...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
d247e7f5df4bd861287467ecc5f827538bee4d63
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d247e7f5df4bd861287467ecc5f827538bee4d63/tokio/src/sync/notify.rs
1,001
1,060
tokio-rs/tokio:tokio/src/sync/notify.rs:27
// Load the state with the lock held. let curr = notify.state.load(SeqCst); if get_num_notify_waiters_calls(curr) != *notify_waiters_calls { // Before we add a waiter to the list we check if these numbers are // different while hol...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
d247e7f5df4bd861287467ecc5f827538bee4d63
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d247e7f5df4bd861287467ecc5f827538bee4d63/tokio/src/sync/notify.rs
1,041
1,100
tokio-rs/tokio:tokio/src/sync/notify.rs:28
} // Explicit drop of the lock to indicate the scope that the // lock is held. Because holding the lock is required to // ensure safe access to fields not held within the lock, it // is helpful to visualize the scope of the critical ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
d247e7f5df4bd861287467ecc5f827538bee4d63
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d247e7f5df4bd861287467ecc5f827538bee4d63/tokio/src/sync/notify.rs
1,081
1,140
tokio-rs/tokio:tokio/src/sync/notify.rs:29
// This is where we ensure safety. The `Notified` value is being // dropped, which means we must ensure that the waiter entry is no // longer stored in the linked list. if matches!(*state, Waiting) { let mut waiters = notify.waiters.lock(); let mut notify_state = notify.s...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
d247e7f5df4bd861287467ecc5f827538bee4d63
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d247e7f5df4bd861287467ecc5f827538bee4d63/tokio/src/sync/notify.rs
1,121
1,177
tokio-rs/tokio:tokio/src/sync/notify.rs:30
type Handle = NonNull<Waiter>; type Target = Waiter; fn as_raw(handle: &NonNull<Waiter>) -> NonNull<Waiter> { *handle } unsafe fn from_raw(ptr: NonNull<Waiter>) -> NonNull<Waiter> { ptr } unsafe fn pointers(target: NonNull<Waiter>) -> NonNull<linked_list::Pointers<Waiter>> { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
d247e7f5df4bd861287467ecc5f827538bee4d63
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d247e7f5df4bd861287467ecc5f827538bee4d63/tokio/src/sync/notify.rs
1,161
1,177
tokio-rs/tokio:tokio/src/sync/notify.rs:11
(data & NOTIFY_WAITERS_CALLS_MASK) | (state & STATE_MASK) } fn get_state(data: usize) -> usize { data & STATE_MASK } fn get_num_notify_waiters_calls(data: usize) -> usize { (data & NOTIFY_WAITERS_CALLS_MASK) >> NOTIFY_WAITERS_SHIFT } fn inc_num_notify_waiters_calls(data: usize) -> usize { data + (1 << NO...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
efe3ab679a05f3da3fcc511a44120239830254f2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/efe3ab679a05f3da3fcc511a44120239830254f2/tokio/src/sync/notify.rs
401
460
tokio-rs/tokio:tokio/src/sync/notify.rs:14
/// available by this call to `notify_one()`. /// /// At most one permit may be stored by `Notify`. Many sequential calls to /// `notify_one` will result in a single permit being stored. The next call to /// `notified().await` will complete immediately, but the one after that /// will wait. /// ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
efe3ab679a05f3da3fcc511a44120239830254f2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/efe3ab679a05f3da3fcc511a44120239830254f2/tokio/src/sync/notify.rs
521
580
tokio-rs/tokio:tokio/src/sync/notify.rs:15
let new = set_state(curr, NOTIFIED); let res = self.state.compare_exchange(curr, new, SeqCst, SeqCst); match res { // No waiters, no further work to do Ok(_) => return, Err(actual) => { curr = actual; } ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
efe3ab679a05f3da3fcc511a44120239830254f2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/efe3ab679a05f3da3fcc511a44120239830254f2/tokio/src/sync/notify.rs
561
620
tokio-rs/tokio:tokio/src/sync/notify.rs:16
/// async fn main() { /// let notify = Arc::new(Notify::new()); /// let notify2 = notify.clone(); /// /// let notified1 = notify.notified(); /// let notified2 = notify.notified(); /// /// let handle = tokio::spawn(async move { /// println!("sending notificatio...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
efe3ab679a05f3da3fcc511a44120239830254f2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/efe3ab679a05f3da3fcc511a44120239830254f2/tokio/src/sync/notify.rs
601
660
tokio-rs/tokio:tokio/src/sync/notify.rs:17
// We move all waiters to a secondary list. It uses a `GuardedLinkedList` // underneath to allow every waiter to safely remove itself from it. // // * This list will be still guarded by the `waiters` lock. // `NotifyWaitersList` wrapper makes sure we hold the lock to modify it. ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
efe3ab679a05f3da3fcc511a44120239830254f2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/efe3ab679a05f3da3fcc511a44120239830254f2/tokio/src/sync/notify.rs
641
700
tokio-rs/tokio:tokio/src/sync/notify.rs:18
wakers.wake_all(); // Acquire the lock again. waiters = self.waiters.lock(); } // Release the lock before notifying drop(waiters); wakers.wake_all(); } } impl Default for Notify { fn default() -> Notify { Notify::new() } } impl UnwindSafe ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
efe3ab679a05f3da3fcc511a44120239830254f2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/efe3ab679a05f3da3fcc511a44120239830254f2/tokio/src/sync/notify.rs
681
740
tokio-rs/tokio:tokio/src/sync/notify.rs:19
// concurrently change as holding the lock is required to // transition **out** of `WAITING`. // // Get a pending waiter let waiter = waiters.pop_back().unwrap(); // Safety: we never make mutable references to waiters. let ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
efe3ab679a05f3da3fcc511a44120239830254f2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/efe3ab679a05f3da3fcc511a44120239830254f2/tokio/src/sync/notify.rs
721
780
tokio-rs/tokio:tokio/src/sync/notify.rs:22
/// /// // Wait for a call to `notify_one`. /// // /// // This uses `.as_mut()` to avoid consuming the future, /// // which lets us call `Pin::set` below. /// future.as_mut().await; /// /// // Reset the future in case an...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
efe3ab679a05f3da3fcc511a44120239830254f2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/efe3ab679a05f3da3fcc511a44120239830254f2/tokio/src/sync/notify.rs
841
900
tokio-rs/tokio:tokio/src/sync/notify.rs:23
fn poll_notified(self: Pin<&mut Self>, waker: Option<&Waker>) -> Poll<()> { use State::*; let (notify, state, notify_waiters_calls, waiter) = self.project(); 'outer_loop: loop { match *state { Init => { let curr = notify.state.load(SeqCst); ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
efe3ab679a05f3da3fcc511a44120239830254f2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/efe3ab679a05f3da3fcc511a44120239830254f2/tokio/src/sync/notify.rs
881
940
tokio-rs/tokio:tokio/src/sync/notify.rs:24
continue 'outer_loop; } // Transition the state to WAITING. loop { match get_state(curr) { EMPTY => { // Transition to WAITING let res = notify...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
efe3ab679a05f3da3fcc511a44120239830254f2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/efe3ab679a05f3da3fcc511a44120239830254f2/tokio/src/sync/notify.rs
921
980
tokio-rs/tokio:tokio/src/sync/notify.rs:25
curr = actual; } } } _ => unreachable!(), } } let mut old_waker = None; if waker.is_some() { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
efe3ab679a05f3da3fcc511a44120239830254f2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/efe3ab679a05f3da3fcc511a44120239830254f2/tokio/src/sync/notify.rs
961
1,020
tokio-rs/tokio:tokio/src/sync/notify.rs:26
drop(unsafe { waiter.waker.with_mut(|waker| (*waker).take()) }); waiter.notification.clear(); *state = Done; return Poll::Ready(()); } // Our waiter was not notified, implying it is still stored in a waiter...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
efe3ab679a05f3da3fcc511a44120239830254f2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/efe3ab679a05f3da3fcc511a44120239830254f2/tokio/src/sync/notify.rs
1,001
1,060
tokio-rs/tokio:tokio/src/sync/notify.rs:27
// We can treat the waiter as notified and remove it from the list, as // it would have been notified in the `notify_waiters` call anyways. // Safety: we hold the lock, so we can modify the waker. old_waker = unsafe { waiter.waker.with_mut(|waker|...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
efe3ab679a05f3da3fcc511a44120239830254f2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/efe3ab679a05f3da3fcc511a44120239830254f2/tokio/src/sync/notify.rs
1,041
1,100
tokio-rs/tokio:tokio/src/sync/notify.rs:28
// Drop the old waker after releasing the lock. drop(old_waker); } Done => { #[cfg(tokio_taskdump)] if let Some(waker) = waker { let mut ctx = Context::from_waker(waker); ready!(cr...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
efe3ab679a05f3da3fcc511a44120239830254f2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/efe3ab679a05f3da3fcc511a44120239830254f2/tokio/src/sync/notify.rs
1,081
1,140
tokio-rs/tokio:tokio/src/sync/notify.rs:29
// `notify_*` functions and we can use the relaxed ordering. let notification = waiter.notification.load(Relaxed); // remove the entry from the list (if not already removed) // // Safety: we hold the lock, so we have an exclusive access to every list the // w...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
efe3ab679a05f3da3fcc511a44120239830254f2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/efe3ab679a05f3da3fcc511a44120239830254f2/tokio/src/sync/notify.rs
1,121
1,169
tokio-rs/tokio:tokio/src/sync/notify.rs:11
(data & NOTIFY_WAITERS_CALLS_MASK) | (state & STATE_MASK) } fn get_state(data: usize) -> usize { data & STATE_MASK } fn get_num_notify_waiters_calls(data: usize) -> usize { (data & NOTIFY_WAITERS_CALLS_MASK) >> NOTIFY_WAITERS_SHIFT } fn inc_num_notify_waiters_calls(data: usize) -> usize { data + (1 << NO...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
7a99f87df203d589d9a8ad042a64b105a954f9fb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7a99f87df203d589d9a8ad042a64b105a954f9fb/tokio/src/sync/notify.rs
401
460
tokio-rs/tokio:tokio/src/sync/notify.rs:14
/// [`notified().await`] will complete immediately consuming the permit made /// available by this call to `notify_one()`. /// /// At most one permit may be stored by `Notify`. Many sequential calls to /// `notify_one` will result in a single permit being stored. The next call to /// `notified().awa...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
7a99f87df203d589d9a8ad042a64b105a954f9fb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7a99f87df203d589d9a8ad042a64b105a954f9fb/tokio/src/sync/notify.rs
521
580
tokio-rs/tokio:tokio/src/sync/notify.rs:15
// operation and a task calling `notified().await`. let new = set_state(curr, NOTIFIED); let res = self.state.compare_exchange(curr, new, SeqCst, SeqCst); match res { // No waiters, no further work to do Ok(_) => return, Err(actual) =>...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
7a99f87df203d589d9a8ad042a64b105a954f9fb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7a99f87df203d589d9a8ad042a64b105a954f9fb/tokio/src/sync/notify.rs
561
620
tokio-rs/tokio:tokio/src/sync/notify.rs:16
/// #[tokio::main] /// async fn main() { /// let notify = Arc::new(Notify::new()); /// let notify2 = notify.clone(); /// /// let notified1 = notify.notified(); /// let notified2 = notify.notified(); /// /// let handle = tokio::spawn(async move { /// printl...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
7a99f87df203d589d9a8ad042a64b105a954f9fb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7a99f87df203d589d9a8ad042a64b105a954f9fb/tokio/src/sync/notify.rs
601
660
tokio-rs/tokio:tokio/src/sync/notify.rs:17
pin!(guard); // We move all waiters to a secondary list. It uses a `GuardedLinkedList` // underneath to allow every waiter to safely remove itself from it. // // * This list will be still guarded by the `waiters` lock. // `NotifyWaitersList` wrapper makes sure we hold the lock...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
7a99f87df203d589d9a8ad042a64b105a954f9fb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7a99f87df203d589d9a8ad042a64b105a954f9fb/tokio/src/sync/notify.rs
641
700
tokio-rs/tokio:tokio/src/sync/notify.rs:18
// be unlinked from the list in `NotifyWaitersList` destructor. wakers.wake_all(); // Acquire the lock again. waiters = self.waiters.lock(); } // Release the lock before notifying drop(waiters); wakers.wake_all(); } } impl Default for Notify { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
7a99f87df203d589d9a8ad042a64b105a954f9fb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7a99f87df203d589d9a8ad042a64b105a954f9fb/tokio/src/sync/notify.rs
681
740
tokio-rs/tokio:tokio/src/sync/notify.rs:19
// At this point, it is guaranteed that the state will not // concurrently change as holding the lock is required to // transition **out** of `WAITING`. // // Get a pending waiter let waiter = waiters.pop_back().unwrap(); /...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
7a99f87df203d589d9a8ad042a64b105a954f9fb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7a99f87df203d589d9a8ad042a64b105a954f9fb/tokio/src/sync/notify.rs
721
780
tokio-rs/tokio:tokio/src/sync/notify.rs:22
/// } /// /// // Wait for a call to `notify_one`. /// // /// // This uses `.as_mut()` to avoid consuming the future, /// // which lets us call `Pin::set` below. /// future.as_mut().await; /// /// // Reset...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
7a99f87df203d589d9a8ad042a64b105a954f9fb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7a99f87df203d589d9a8ad042a64b105a954f9fb/tokio/src/sync/notify.rs
841
900
tokio-rs/tokio:tokio/src/sync/notify.rs:23
} fn poll_notified(self: Pin<&mut Self>, waker: Option<&Waker>) -> Poll<()> { use State::*; let (notify, state, notify_waiters_calls, waiter) = self.project(); 'outer_loop: loop { match *state { Init => { let curr = notify.state.load(SeqCst)...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
7a99f87df203d589d9a8ad042a64b105a954f9fb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7a99f87df203d589d9a8ad042a64b105a954f9fb/tokio/src/sync/notify.rs
881
940
tokio-rs/tokio:tokio/src/sync/notify.rs:24
*state = Done; continue 'outer_loop; } // Transition the state to WAITING. loop { match get_state(curr) { EMPTY => { // Transition to WAITING ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
7a99f87df203d589d9a8ad042a64b105a954f9fb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7a99f87df203d589d9a8ad042a64b105a954f9fb/tokio/src/sync/notify.rs
921
980
tokio-rs/tokio:tokio/src/sync/notify.rs:25
assert_eq!(get_state(actual), EMPTY); curr = actual; } } } _ => unreachable!(), } } let mut...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
7a99f87df203d589d9a8ad042a64b105a954f9fb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7a99f87df203d589d9a8ad042a64b105a954f9fb/tokio/src/sync/notify.rs
961
1,020
tokio-rs/tokio:tokio/src/sync/notify.rs:26
// so we have an exclusive access to `waker`. drop(unsafe { waiter.waker.with_mut(|waker| (*waker).take()) }); waiter.notification.clear(); *state = Done; return Poll::Ready(()); } /...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
7a99f87df203d589d9a8ad042a64b105a954f9fb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7a99f87df203d589d9a8ad042a64b105a954f9fb/tokio/src/sync/notify.rs
1,001
1,060
tokio-rs/tokio:tokio/src/sync/notify.rs:27
// waiter must be contained by a guarded list used in `notify_waiters`. // We can treat the waiter as notified and remove it from the list, as // it would have been notified in the `notify_waiters` call anyways. // Safety: we hold the lock, so we ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
7a99f87df203d589d9a8ad042a64b105a954f9fb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7a99f87df203d589d9a8ad042a64b105a954f9fb/tokio/src/sync/notify.rs
1,041
1,100
tokio-rs/tokio:tokio/src/sync/notify.rs:28
drop(waiters); // Drop the old waker after releasing the lock. drop(old_waker); } Done => { #[cfg(tokio_taskdump)] if let Some(waker) = waker { let mut ctx = Context::from_waker(waker...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
7a99f87df203d589d9a8ad042a64b105a954f9fb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7a99f87df203d589d9a8ad042a64b105a954f9fb/tokio/src/sync/notify.rs
1,081
1,140
tokio-rs/tokio:tokio/src/sync/notify.rs:22
/// } /// /// // Wait for a call to `notify_one`. /// // /// // This uses `.as_mut()` to avoid consuming the future, /// // which lets us call `Pin::set` below. /// future.as_mut().await; /// /// // Reset...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
db543639e159453367a178c4ae7dde88c718cac8
github
async-runtime
https://github.com/tokio-rs/tokio/blob/db543639e159453367a178c4ae7dde88c718cac8/tokio/src/sync/notify.rs
841
900
tokio-rs/tokio:tokio/src/sync/notify.rs:23
} fn poll_notified(self: Pin<&mut Self>, waker: Option<&Waker>) -> Poll<()> { use State::*; let (notify, state, notify_waiters_calls, waiter) = self.project(); loop { match *state { Init => { let curr = notify.state.load(SeqCst); ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
db543639e159453367a178c4ae7dde88c718cac8
github
async-runtime
https://github.com/tokio-rs/tokio/blob/db543639e159453367a178c4ae7dde88c718cac8/tokio/src/sync/notify.rs
881
940
tokio-rs/tokio:tokio/src/sync/notify.rs:24
*state = Done; return Poll::Ready(()); } // Transition the state to WAITING. loop { match get_state(curr) { EMPTY => { // Transition to WAITING ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
db543639e159453367a178c4ae7dde88c718cac8
github
async-runtime
https://github.com/tokio-rs/tokio/blob/db543639e159453367a178c4ae7dde88c718cac8/tokio/src/sync/notify.rs
921
980
tokio-rs/tokio:tokio/src/sync/notify.rs:25
assert_eq!(get_state(actual), EMPTY); curr = actual; } } } _ => unreachable!(), } } let mut...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
db543639e159453367a178c4ae7dde88c718cac8
github
async-runtime
https://github.com/tokio-rs/tokio/blob/db543639e159453367a178c4ae7dde88c718cac8/tokio/src/sync/notify.rs
961
1,020
tokio-rs/tokio:tokio/src/sync/notify.rs:26
} // Our waiter was not notified, implying it is still stored in a waiter // list (guarded by `notify.waiters`). In order to access the waker // fields, we must acquire the lock. let mut old_waker = None; let mut waite...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
db543639e159453367a178c4ae7dde88c718cac8
github
async-runtime
https://github.com/tokio-rs/tokio/blob/db543639e159453367a178c4ae7dde88c718cac8/tokio/src/sync/notify.rs
1,001
1,060
tokio-rs/tokio:tokio/src/sync/notify.rs:27
// Safety: we hold the lock, so we have an exclusive access to the list. // The list is used in `notify_waiters`, so it must be guarded. unsafe { waiters.remove(NonNull::from(waiter)) }; *state = Done; } else { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
db543639e159453367a178c4ae7dde88c718cac8
github
async-runtime
https://github.com/tokio-rs/tokio/blob/db543639e159453367a178c4ae7dde88c718cac8/tokio/src/sync/notify.rs
1,041
1,100
tokio-rs/tokio:tokio/src/sync/notify.rs:28
return Poll::Ready(()); } } } } } impl Future for Notified<'_> { type Output = (); fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<()> { self.poll_notified(Some(cx.waker())) } } impl Drop for Notified<'_> { fn drop(&mut self) { use S...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
db543639e159453367a178c4ae7dde88c718cac8
github
async-runtime
https://github.com/tokio-rs/tokio/blob/db543639e159453367a178c4ae7dde88c718cac8/tokio/src/sync/notify.rs
1,081
1,140
tokio-rs/tokio:tokio/src/sync/notify.rs:29
if waiters.is_empty() && get_state(notify_state) == WAITING { notify_state = set_state(notify_state, EMPTY); notify.state.store(notify_state, SeqCst); } // See if the node was notified but not received. In this case, if // the notification was trigger...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
db543639e159453367a178c4ae7dde88c718cac8
github
async-runtime
https://github.com/tokio-rs/tokio/blob/db543639e159453367a178c4ae7dde88c718cac8/tokio/src/sync/notify.rs
1,121
1,159
tokio-rs/tokio:tokio/src/sync/notify.rs:1
// Allow `unreachable_pub` warnings when sync is not enabled // due to the usage of `Notify` within the `rt` feature set. // When this module is compiled with `sync` enabled we will warn on // this lint. When `rt` is enabled we use `pub(crate)` which // triggers this warning but it is safe to ignore in this case. #![cf...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
ee09e04c31d1c6938f835354cef6b23f1b13b8e7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ee09e04c31d1c6938f835354cef6b23f1b13b8e7/tokio/src/sync/notify.rs
1
60
tokio-rs/tokio:tokio/src/sync/notify.rs:6
pub struct Notify { // `state` uses 2 bits to store one of `EMPTY`, // `WAITING` or `NOTIFIED`. The rest of the bits // are used to store the number of times `notify_waiters` // was called. // // Throughout the code there are two assumptions: // - state can be transitioned *from* `WAITING` o...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
ee09e04c31d1c6938f835354cef6b23f1b13b8e7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ee09e04c31d1c6938f835354cef6b23f1b13b8e7/tokio/src/sync/notify.rs
201
260
tokio-rs/tokio:tokio/src/sync/notify.rs:7
Waiter { pointers: linked_list::Pointers::new(), waker: None, notified: None, _p: PhantomPinned, } } } generate_addr_of_methods! { impl<> Waiter { unsafe fn addr_of_pointers(self: NonNull<Self>) -> NonNull<linked_list::Pointers<Waiter>> { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
ee09e04c31d1c6938f835354cef6b23f1b13b8e7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ee09e04c31d1c6938f835354cef6b23f1b13b8e7/tokio/src/sync/notify.rs
241
300
tokio-rs/tokio:tokio/src/sync/notify.rs:8
} /// Removes the last element from the guarded list. Modifying this list /// requires an exclusive access to the main list in `Notify`. fn pop_back_locked(&mut self, _waiters: &mut WaitList) -> Option<NonNull<Waiter>> { let result = self.list.pop_back(); if result.is_none() { /...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
ee09e04c31d1c6938f835354cef6b23f1b13b8e7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ee09e04c31d1c6938f835354cef6b23f1b13b8e7/tokio/src/sync/notify.rs
281
340
tokio-rs/tokio:tokio/src/sync/notify.rs:9
state: State, /// Number of calls to `notify_waiters` at the time of creation. notify_waiters_calls: usize, /// Entry in the waiter `LinkedList`. waiter: UnsafeCell<Waiter>, } unsafe impl<'a> Send for Notified<'a> {} unsafe impl<'a> Sync for Notified<'a> {} #[derive(Debug)] enum State { Init, ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
ee09e04c31d1c6938f835354cef6b23f1b13b8e7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ee09e04c31d1c6938f835354cef6b23f1b13b8e7/tokio/src/sync/notify.rs
321
380
tokio-rs/tokio:tokio/src/sync/notify.rs:10
fn get_num_notify_waiters_calls(data: usize) -> usize { (data & NOTIFY_WAITERS_CALLS_MASK) >> NOTIFY_WAITERS_SHIFT } fn inc_num_notify_waiters_calls(data: usize) -> usize { data + (1 << NOTIFY_WAITERS_SHIFT) } fn atomic_inc_num_notify_waiters_calls(data: &AtomicUsize) { data.fetch_add(1 << NOTIFY_WAITERS_...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
ee09e04c31d1c6938f835354cef6b23f1b13b8e7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ee09e04c31d1c6938f835354cef6b23f1b13b8e7/tokio/src/sync/notify.rs
361
420
tokio-rs/tokio:tokio/src/sync/notify.rs:13
/// /// [`notified().await`]: Notify::notified() /// /// # Examples /// /// ``` /// use tokio::sync::Notify; /// use std::sync::Arc; /// /// #[tokio::main] /// async fn main() { /// let notify = Arc::new(Notify::new()); /// let notify2 = notify.clone(); /// ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
ee09e04c31d1c6938f835354cef6b23f1b13b8e7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ee09e04c31d1c6938f835354cef6b23f1b13b8e7/tokio/src/sync/notify.rs
481
540
tokio-rs/tokio:tokio/src/sync/notify.rs:14
Err(actual) => { curr = actual; } } } // There are waiters, the lock must be acquired to notify. let mut waiters = self.waiters.lock(); // The state must be reloaded while the lock is held. The state may only // transition out of ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
ee09e04c31d1c6938f835354cef6b23f1b13b8e7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ee09e04c31d1c6938f835354cef6b23f1b13b8e7/tokio/src/sync/notify.rs
521
580
tokio-rs/tokio:tokio/src/sync/notify.rs:15
/// /// let handle = tokio::spawn(async move { /// println!("sending notifications"); /// notify2.notify_waiters(); /// }); /// /// notified1.await; /// notified2.await; /// println!("received notifications"); /// } /// ``` pub fn notify_wa...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
ee09e04c31d1c6938f835354cef6b23f1b13b8e7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ee09e04c31d1c6938f835354cef6b23f1b13b8e7/tokio/src/sync/notify.rs
561
620
tokio-rs/tokio:tokio/src/sync/notify.rs:16
// * This wrapper will empty the list on drop. It is critical for safety // that we will not leave any list entry with a pointer to the local // guard node after this function returns / panics. let mut list = NotifyWaitersList::new(std::mem::take(&mut *waiters), guard, self); let mu...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
ee09e04c31d1c6938f835354cef6b23f1b13b8e7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ee09e04c31d1c6938f835354cef6b23f1b13b8e7/tokio/src/sync/notify.rs
601
660
tokio-rs/tokio:tokio/src/sync/notify.rs:17
wakers.wake_all(); } } impl Default for Notify { fn default() -> Notify { Notify::new() } } impl UnwindSafe for Notify {} impl RefUnwindSafe for Notify {} fn notify_locked(waiters: &mut WaitList, state: &AtomicUsize, curr: usize) -> Option<Waker> { loop { match get_state(curr) { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
ee09e04c31d1c6938f835354cef6b23f1b13b8e7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ee09e04c31d1c6938f835354cef6b23f1b13b8e7/tokio/src/sync/notify.rs
641
700
tokio-rs/tokio:tokio/src/sync/notify.rs:18
assert!(waiter.notified.is_none()); waiter.notified = Some(NotificationType::OneWaiter); let waker = waiter.waker.take(); if waiters.is_empty() { // As this the **final** waiter in the list, the state // must be transitioned to `E...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
ee09e04c31d1c6938f835354cef6b23f1b13b8e7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ee09e04c31d1c6938f835354cef6b23f1b13b8e7/tokio/src/sync/notify.rs
681
740
tokio-rs/tokio:tokio/src/sync/notify.rs:21
/// future.set(self.notify_on_sent.notified()); /// } /// } /// } /// ``` /// /// [`notify_one`]: Notify::notify_one() /// [`notify_waiters`]: Notify::notify_waiters() pub fn enable(self: Pin<&mut Self>) -> bool { self.poll_notified(None).is_ready() } ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
ee09e04c31d1c6938f835354cef6b23f1b13b8e7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ee09e04c31d1c6938f835354cef6b23f1b13b8e7/tokio/src/sync/notify.rs
801
860
tokio-rs/tokio:tokio/src/sync/notify.rs:22
let curr = notify.state.load(SeqCst); // Optimistically try acquiring a pending notification let res = notify.state.compare_exchange( set_state(curr, NOTIFIED), set_state(curr, EMPTY), SeqCst, ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
ee09e04c31d1c6938f835354cef6b23f1b13b8e7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ee09e04c31d1c6938f835354cef6b23f1b13b8e7/tokio/src/sync/notify.rs
841
900
tokio-rs/tokio:tokio/src/sync/notify.rs:23
set_state(curr, EMPTY), set_state(curr, WAITING), SeqCst, SeqCst, ); if let Err(actual) = res { assert_eq!(get_...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
ee09e04c31d1c6938f835354cef6b23f1b13b8e7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ee09e04c31d1c6938f835354cef6b23f1b13b8e7/tokio/src/sync/notify.rs
881
940
tokio-rs/tokio:tokio/src/sync/notify.rs:24
if waker.is_some() { // Safety: called while locked. // // The use of `old_waiter` here is not necessary, as the field is always // None when we reach this line. unsafe { o...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
ee09e04c31d1c6938f835354cef6b23f1b13b8e7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ee09e04c31d1c6938f835354cef6b23f1b13b8e7/tokio/src/sync/notify.rs
921
980
tokio-rs/tokio:tokio/src/sync/notify.rs:25
w.notified = None; *state = Done; } else if get_num_notify_waiters_calls(curr) != *notify_waiters_calls { // Before we add a waiter to the list we check if these numbers are // different while holding the lock. If these numbers ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
ee09e04c31d1c6938f835354cef6b23f1b13b8e7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ee09e04c31d1c6938f835354cef6b23f1b13b8e7/tokio/src/sync/notify.rs
961
1,020
tokio-rs/tokio:tokio/src/sync/notify.rs:26
// section. drop(waiters); // Drop the old waker after releasing the lock. drop(old_waker); } Done => { return Poll::Ready(()); } } } } } impl Future for Notified<'_>...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
ee09e04c31d1c6938f835354cef6b23f1b13b8e7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ee09e04c31d1c6938f835354cef6b23f1b13b8e7/tokio/src/sync/notify.rs
1,001
1,060
tokio-rs/tokio:tokio/src/sync/notify.rs:27
// list, then it is contained by a guarded list used by `notify_waiters` and // in such case it must be a middle node. unsafe { waiters.remove(NonNull::new_unchecked(waiter.get())) }; if waiters.is_empty() && get_state(notify_state) == WAITING { notify_state = set_st...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
ee09e04c31d1c6938f835354cef6b23f1b13b8e7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ee09e04c31d1c6938f835354cef6b23f1b13b8e7/tokio/src/sync/notify.rs
1,041
1,089
tokio-rs/tokio:tokio/src/sync/notify.rs:23
set_state(curr, EMPTY), set_state(curr, WAITING), SeqCst, SeqCst, ); if let Err(actual) = res { assert_eq!(get_...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
795754a846a29a0c785d4dadfb7a9136f8aba1ab
github
async-runtime
https://github.com/tokio-rs/tokio/blob/795754a846a29a0c785d4dadfb7a9136f8aba1ab/tokio/src/sync/notify.rs
881
940