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:24
// Safety: called while locked. unsafe { (*waiter.get()).waker = waker; } } // Insert the waiter into the linked list // // safety: pointers from `UnsafeCell` are ...
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
921
980
tokio-rs/tokio:tokio/src/sync/notify.rs:25
// it would have been notified in the `notify_waiters` call anyways. w.waker = None; // 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. ...
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
961
1,020
tokio-rs/tokio:tokio/src/sync/notify.rs:26
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 State::*; // Safety: The type only transitions to a "Waiting" state when pinned. let (notify, ...
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
1,001
1,060
tokio-rs/tokio:tokio/src/sync/notify.rs:27
if matches!( unsafe { (*waiter.get()).notified }, Some(NotificationType::OneWaiter) ) { if let Some(waker) = notify_locked(&mut waiters, &notify.state, notify_state) { drop(waiters); waker.wake(); } ...
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
1,041
1,074
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
203a079743629db4685d6903d11089143f035f7b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/203a079743629db4685d6903d11089143f035f7b/tokio/src/sync/notify.rs
1
60
tokio-rs/tokio:tokio/src/sync/notify.rs:6
// This 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. state: AtomicUsize, waiters: Mutex<WaitList>, } #[derive(Debug, Clone, Copy)] enum NotificationType { // Notification triggered ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
203a079743629db4685d6903d11089143f035f7b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/203a079743629db4685d6903d11089143f035f7b/tokio/src/sync/notify.rs
201
260
tokio-rs/tokio:tokio/src/sync/notify.rs:7
/// /// This future is fused, so once it has completed, any future calls to poll /// 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, /// Entry in ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
203a079743629db4685d6903d11089143f035f7b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/203a079743629db4685d6903d11089143f035f7b/tokio/src/sync/notify.rs
241
300
tokio-rs/tokio:tokio/src/sync/notify.rs:8
} 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 << NOTIFY_WAITERS_SHIFT) } fn atomic_inc_num_notify_waiters_ca...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
203a079743629db4685d6903d11089143f035f7b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/203a079743629db4685d6903d11089143f035f7b/tokio/src/sync/notify.rs
281
340
tokio-rs/tokio:tokio/src/sync/notify.rs:11
/// /// 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 `notify_one()`. /// /// At most one permit m...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
203a079743629db4685d6903d11089143f035f7b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/203a079743629db4685d6903d11089143f035f7b/tokio/src/sync/notify.rs
401
460
tokio-rs/tokio:tokio/src/sync/notify.rs:12
while let EMPTY | NOTIFIED = get_state(curr) { // The compare-exchange from `NOTIFIED` -> `NOTIFIED` is intended. A // happens-before synchronization must happen between this atomic // operation and a task calling `notified().await`. let new = set_state(curr, NOTIFIED); ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
203a079743629db4685d6903d11089143f035f7b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/203a079743629db4685d6903d11089143f035f7b/tokio/src/sync/notify.rs
441
500
tokio-rs/tokio:tokio/src/sync/notify.rs:13
/// 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(); /// let notified2 = notify.notified(); /// ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
203a079743629db4685d6903d11089143f035f7b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/203a079743629db4685d6903d11089143f035f7b/tokio/src/sync/notify.rs
481
540
tokio-rs/tokio:tokio/src/sync/notify.rs:14
// transition **out** of `WAITING`. 'outer: loop { while wakers.can_push() { match waiters.pop_back() { Some(mut waiter) => { // Safety: `waiters` lock is still held. let waiter = unsafe { waiter.as_mut() }; ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
203a079743629db4685d6903d11089143f035f7b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/203a079743629db4685d6903d11089143f035f7b/tokio/src/sync/notify.rs
521
580
tokio-rs/tokio:tokio/src/sync/notify.rs:15
} } 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) { EMPTY | NOTIFIED...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
203a079743629db4685d6903d11089143f035f7b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/203a079743629db4685d6903d11089143f035f7b/tokio/src/sync/notify.rs
561
620
tokio-rs/tokio:tokio/src/sync/notify.rs:19
/// } /// } /// ``` /// /// [`notify_one`]: Notify::notify_one() /// [`notify_waiters`]: Notify::notify_waiters() pub fn enable(self: Pin<&mut Self>) -> bool { self.poll_notified(None).is_ready() } /// A custom `project` implementation is used in place of `pin-project-lite` ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
203a079743629db4685d6903d11089143f035f7b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/203a079743629db4685d6903d11089143f035f7b/tokio/src/sync/notify.rs
721
780
tokio-rs/tokio:tokio/src/sync/notify.rs:20
); if res.is_ok() { // Acquired the notification *state = Done; return Poll::Ready(()); } // Clone the waker before locking, a waker clone can be // triggering arbitr...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
203a079743629db4685d6903d11089143f035f7b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/203a079743629db4685d6903d11089143f035f7b/tokio/src/sync/notify.rs
761
820
tokio-rs/tokio:tokio/src/sync/notify.rs:21
curr = actual; } else { break; } } WAITING => break, NOTIFIED => { // Try consuming the notification ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
203a079743629db4685d6903d11089143f035f7b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/203a079743629db4685d6903d11089143f035f7b/tokio/src/sync/notify.rs
801
860
tokio-rs/tokio:tokio/src/sync/notify.rs:22
// safety: pointers from `UnsafeCell` are never null. waiters.push_front(unsafe { NonNull::new_unchecked(waiter.get()) }); *state = Waiting; return Poll::Pending; } Waiting => { // Currently in the "Waiting...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
203a079743629db4685d6903d11089143f035f7b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/203a079743629db4685d6903d11089143f035f7b/tokio/src/sync/notify.rs
841
900
tokio-rs/tokio:tokio/src/sync/notify.rs:23
// 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
203a079743629db4685d6903d11089143f035f7b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/203a079743629db4685d6903d11089143f035f7b/tokio/src/sync/notify.rs
881
940
tokio-rs/tokio:tokio/src/sync/notify.rs:24
// being the only `LinkedList` available to the type. unsafe { waiters.remove(NonNull::new_unchecked(waiter.get())) }; if waiters.is_empty() && get_state(notify_state) == WAITING { notify_state = set_state(notify_state, EMPTY); notify.state.store(notify_state, Se...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
203a079743629db4685d6903d11089143f035f7b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/203a079743629db4685d6903d11089143f035f7b/tokio/src/sync/notify.rs
921
968
tokio-rs/tokio:tokio/src/sync/notify.rs:6
// `WAITING` or `NOTIFIED`. The rest of the bits // are used to store the number of times `notify_waiters` // was called. state: AtomicUsize, waiters: Mutex<WaitList>, } #[derive(Debug, Clone, Copy)] enum NotificationType { // Notification triggered by calling `notify_waiters` AllWaiters, /...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
6f048ca954aa5f285f1cf6310d447e7c079c1c3d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6f048ca954aa5f285f1cf6310d447e7c079c1c3d/tokio/src/sync/notify.rs
201
260
tokio-rs/tokio:tokio/src/sync/notify.rs:7
/// This future is fused, so once it has completed, any future calls to poll /// 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, /// Entry in the ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
6f048ca954aa5f285f1cf6310d447e7c079c1c3d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6f048ca954aa5f285f1cf6310d447e7c079c1c3d/tokio/src/sync/notify.rs
241
300
tokio-rs/tokio:tokio/src/sync/notify.rs:8
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 << NOTIFY_WAITERS_SHIFT) } fn atomic_inc_num_notify_waiters_calls...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
6f048ca954aa5f285f1cf6310d447e7c079c1c3d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6f048ca954aa5f285f1cf6310d447e7c079c1c3d/tokio/src/sync/notify.rs
281
340
tokio-rs/tokio:tokio/src/sync/notify.rs:11
/// 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 `notify_one()`. /// /// At most one permit may be st...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
6f048ca954aa5f285f1cf6310d447e7c079c1c3d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6f048ca954aa5f285f1cf6310d447e7c079c1c3d/tokio/src/sync/notify.rs
401
460
tokio-rs/tokio:tokio/src/sync/notify.rs:12
// The compare-exchange from `NOTIFIED` -> `NOTIFIED` is intended. A // happens-before synchronization must happen between this atomic // operation and a task calling `notified().await`. let new = set_state(curr, NOTIFIED); let res = self.state.compare_exchange(curr, new,...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
6f048ca954aa5f285f1cf6310d447e7c079c1c3d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6f048ca954aa5f285f1cf6310d447e7c079c1c3d/tokio/src/sync/notify.rs
441
500
tokio-rs/tokio:tokio/src/sync/notify.rs:13
/// use std::sync::Arc; /// /// #[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...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
6f048ca954aa5f285f1cf6310d447e7c079c1c3d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6f048ca954aa5f285f1cf6310d447e7c079c1c3d/tokio/src/sync/notify.rs
481
540
tokio-rs/tokio:tokio/src/sync/notify.rs:14
'outer: loop { while wakers.can_push() { match waiters.pop_back() { Some(mut waiter) => { // Safety: `waiters` lock is still held. let waiter = unsafe { waiter.as_mut() }; assert!(waiter.notified.is_...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
6f048ca954aa5f285f1cf6310d447e7c079c1c3d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6f048ca954aa5f285f1cf6310d447e7c079c1c3d/tokio/src/sync/notify.rs
521
580
tokio-rs/tokio:tokio/src/sync/notify.rs:15
} impl Default for Notify { fn default() -> Notify { Notify::new() } } fn notify_locked(waiters: &mut WaitList, state: &AtomicUsize, curr: usize) -> Option<Waker> { loop { match get_state(curr) { EMPTY | NOTIFIED => { let res = state.compare_exchange(curr, set_s...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
6f048ca954aa5f285f1cf6310d447e7c079c1c3d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6f048ca954aa5f285f1cf6310d447e7c079c1c3d/tokio/src/sync/notify.rs
561
620
tokio-rs/tokio:tokio/src/sync/notify.rs:19
/// [`notify_one`]: Notify::notify_one() /// [`notify_waiters`]: Notify::notify_waiters() pub fn enable(self: Pin<&mut Self>) -> bool { self.poll_notified(None).is_ready() } /// A custom `project` implementation is used in place of `pin-project-lite` /// as a custom drop implementation is n...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
6f048ca954aa5f285f1cf6310d447e7c079c1c3d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6f048ca954aa5f285f1cf6310d447e7c079c1c3d/tokio/src/sync/notify.rs
721
780
tokio-rs/tokio:tokio/src/sync/notify.rs:20
*state = Done; return Poll::Ready(()); } // Clone the waker before locking, a waker clone can be // triggering arbitrary code. let waker = waker.cloned(); // Acquire the lock and attempt to tran...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
6f048ca954aa5f285f1cf6310d447e7c079c1c3d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6f048ca954aa5f285f1cf6310d447e7c079c1c3d/tokio/src/sync/notify.rs
761
820
tokio-rs/tokio:tokio/src/sync/notify.rs:21
} WAITING => break, NOTIFIED => { // Try consuming the notification let res = notify.state.compare_exchange( set_state(curr, NOTIFIED), ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
6f048ca954aa5f285f1cf6310d447e7c079c1c3d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6f048ca954aa5f285f1cf6310d447e7c079c1c3d/tokio/src/sync/notify.rs
801
860
tokio-rs/tokio:tokio/src/sync/notify.rs:22
return Poll::Pending; } Waiting => { // Currently in the "Waiting" state, implying the caller has // a waiter stored in the waiter list (guarded by // `notify.waiters`). In order to access the waker fields, /...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
6f048ca954aa5f285f1cf6310d447e7c079c1c3d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6f048ca954aa5f285f1cf6310d447e7c079c1c3d/tokio/src/sync/notify.rs
841
900
tokio-rs/tokio:tokio/src/sync/notify.rs:23
// section. drop(waiters); } Done => { return Poll::Ready(()); } } } } } impl Future for Notified<'_> { type Output = (); fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<()> { se...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
6f048ca954aa5f285f1cf6310d447e7c079c1c3d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6f048ca954aa5f285f1cf6310d447e7c079c1c3d/tokio/src/sync/notify.rs
881
940
tokio-rs/tokio:tokio/src/sync/notify.rs:24
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 triggered via `notify_one`, it must be sent // to the next waiter. ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
6f048ca954aa5f285f1cf6310d447e7c079c1c3d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6f048ca954aa5f285f1cf6310d447e7c079c1c3d/tokio/src/sync/notify.rs
921
964
tokio-rs/tokio:tokio/src/sync/notify.rs:5
/// let mut locked_queue = self.messages.lock().unwrap(); /// locked_queue.pop_front() /// } /// /// pub async fn recv(&self) -> T { /// let future = self.notify_on_sent.notified(); /// tokio::pin!(future); /// /// loop { /// // Make sure that no wakeup is los...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
c7280167db887bda9d6e6c009bf1c229268254d6
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c7280167db887bda9d6e6c009bf1c229268254d6/tokio/src/sync/notify.rs
161
220
tokio-rs/tokio:tokio/src/sync/notify.rs:6
// `WAITING` or `NOTIFIED`. The rest of the bits // are used to store the number of times `notify_waiters` // was called. state: AtomicUsize, waiters: Mutex<WaitList>, } #[derive(Debug, Clone, Copy)] enum NotificationType { // Notification triggered by calling `notify_waiters` AllWaiters, /...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
c7280167db887bda9d6e6c009bf1c229268254d6
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c7280167db887bda9d6e6c009bf1c229268254d6/tokio/src/sync/notify.rs
201
260
tokio-rs/tokio:tokio/src/sync/notify.rs:7
/// The current state of the receiving process. state: State, /// 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(usize), Waiting, Done, } const NOTIFY_WAITERS...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
c7280167db887bda9d6e6c009bf1c229268254d6
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c7280167db887bda9d6e6c009bf1c229268254d6/tokio/src/sync/notify.rs
241
300
tokio-rs/tokio:tokio/src/sync/notify.rs:8
} 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_SHIFT, SeqCst); } impl Notify { /// Create a new `Notify`, initialized without a permit. /// /// # Example...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
c7280167db887bda9d6e6c009bf1c229268254d6
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c7280167db887bda9d6e6c009bf1c229268254d6/tokio/src/sync/notify.rs
281
340
tokio-rs/tokio:tokio/src/sync/notify.rs:11
/// `notified().await` will complete immediately, but the one after that /// will wait. /// /// [`notified().await`]: Notify::notified() /// /// # Examples /// /// ``` /// use tokio::sync::Notify; /// use std::sync::Arc; /// /// #[tokio::main] /// async fn main() { //...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
c7280167db887bda9d6e6c009bf1c229268254d6
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c7280167db887bda9d6e6c009bf1c229268254d6/tokio/src/sync/notify.rs
401
460
tokio-rs/tokio:tokio/src/sync/notify.rs:12
// No waiters, no further work to do Ok(_) => return, Err(actual) => { curr = actual; } } } // There are waiters, the lock must be acquired to notify. let mut waiters = self.waiters.lock(); // The state mus...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
c7280167db887bda9d6e6c009bf1c229268254d6
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c7280167db887bda9d6e6c009bf1c229268254d6/tokio/src/sync/notify.rs
441
500
tokio-rs/tokio:tokio/src/sync/notify.rs:13
/// let notified1 = notify.notified(); /// let notified2 = notify.notified(); /// /// let handle = tokio::spawn(async move { /// println!("sending notifications"); /// notify2.notify_waiters(); /// }); /// /// notified1.await; /// notified2.awa...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
c7280167db887bda9d6e6c009bf1c229268254d6
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c7280167db887bda9d6e6c009bf1c229268254d6/tokio/src/sync/notify.rs
481
540
tokio-rs/tokio:tokio/src/sync/notify.rs:14
assert!(waiter.notified.is_none()); waiter.notified = Some(NotificationType::AllWaiters); if let Some(waker) = waiter.waker.take() { wakers.push(waker); } } None => { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
c7280167db887bda9d6e6c009bf1c229268254d6
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c7280167db887bda9d6e6c009bf1c229268254d6/tokio/src/sync/notify.rs
521
580
tokio-rs/tokio:tokio/src/sync/notify.rs:15
fn notify_locked(waiters: &mut WaitList, state: &AtomicUsize, curr: usize) -> Option<Waker> { loop { match get_state(curr) { EMPTY | NOTIFIED => { let res = state.compare_exchange(curr, set_state(curr, NOTIFIED), SeqCst, SeqCst); match res { O...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
c7280167db887bda9d6e6c009bf1c229268254d6
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c7280167db887bda9d6e6c009bf1c229268254d6/tokio/src/sync/notify.rs
561
620
tokio-rs/tokio:tokio/src/sync/notify.rs:18
/// /// pub fn try_recv(&self) -> Option<T> { /// let mut locked_queue = self.messages.lock().unwrap(); /// locked_queue.pop_front() /// } /// /// pub async fn recv(&self) -> T { /// let future = self.notify_on_sent.notified(); /// tokio::pin!(...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
c7280167db887bda9d6e6c009bf1c229268254d6
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c7280167db887bda9d6e6c009bf1c229268254d6/tokio/src/sync/notify.rs
681
740
tokio-rs/tokio:tokio/src/sync/notify.rs:19
/// as a custom drop implementation is needed. fn project(self: Pin<&mut Self>) -> (&Notify, &mut State, &UnsafeCell<Waiter>) { unsafe { // Safety: both `notify` and `state` are `Unpin`. is_unpin::<&Notify>(); is_unpin::<AtomicUsize>(); let me = self.get_unc...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
c7280167db887bda9d6e6c009bf1c229268254d6
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c7280167db887bda9d6e6c009bf1c229268254d6/tokio/src/sync/notify.rs
721
780
tokio-rs/tokio:tokio/src/sync/notify.rs:20
// Acquire the lock and attempt to transition to the waiting // state. let mut waiters = notify.waiters.lock(); // Reload the state with the lock held let mut curr = notify.state.load(SeqCst); // if notify_waiters has ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
c7280167db887bda9d6e6c009bf1c229268254d6
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c7280167db887bda9d6e6c009bf1c229268254d6/tokio/src/sync/notify.rs
761
820
tokio-rs/tokio:tokio/src/sync/notify.rs:21
SeqCst, SeqCst, ); match res { Ok(_) => { // Acquired the notification *state = Done; ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
c7280167db887bda9d6e6c009bf1c229268254d6
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c7280167db887bda9d6e6c009bf1c229268254d6/tokio/src/sync/notify.rs
801
860
tokio-rs/tokio:tokio/src/sync/notify.rs:22
// we must hold the lock. let waiters = notify.waiters.lock(); // Safety: called while locked let w = unsafe { &mut *waiter.get() }; if w.notified.is_some() { // Our waker has been notified. Reset the fields and ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
c7280167db887bda9d6e6c009bf1c229268254d6
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c7280167db887bda9d6e6c009bf1c229268254d6/tokio/src/sync/notify.rs
841
900
tokio-rs/tokio:tokio/src/sync/notify.rs:23
} } } 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 State::*; // Safety: The type only transitions to a "Wai...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
c7280167db887bda9d6e6c009bf1c229268254d6
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c7280167db887bda9d6e6c009bf1c229268254d6/tokio/src/sync/notify.rs
881
940
tokio-rs/tokio:tokio/src/sync/notify.rs:24
// // Safety: with the entry removed from the linked list, there can be // no concurrent access to the entry if matches!( unsafe { (*waiter.get()).notified }, Some(NotificationType::OneWaiter) ) { if let Some(waker) = notify...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
c7280167db887bda9d6e6c009bf1c229268254d6
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c7280167db887bda9d6e6c009bf1c229268254d6/tokio/src/sync/notify.rs
921
957
tokio-rs/tokio:tokio/src/sync/notify.rs:21
SeqCst, SeqCst, ); match res { Ok(_) => { // Acquired the notification *state = Done; ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
a7e7eca893e7df1396b42a98943ccfb64a5bc74b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a7e7eca893e7df1396b42a98943ccfb64a5bc74b/tokio/src/sync/notify.rs
801
860
tokio-rs/tokio:tokio/src/sync/notify.rs:22
// we must hold the lock. let waiters = notify.waiters.lock(); // Safety: called while locked let w = unsafe { &mut *waiter.get() }; if w.notified.is_some() { // Our waker has been notified. Reset the fields and ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
a7e7eca893e7df1396b42a98943ccfb64a5bc74b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a7e7eca893e7df1396b42a98943ccfb64a5bc74b/tokio/src/sync/notify.rs
841
900
tokio-rs/tokio:tokio/src/sync/notify.rs:21
SeqCst, SeqCst, ); match res { Ok(_) => { // Acquired the notification *state = Done; ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
0d4d3c34f16383b155332460a7a96ef7ca681634
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0d4d3c34f16383b155332460a7a96ef7ca681634/tokio/src/sync/notify.rs
801
860
tokio-rs/tokio:tokio/src/sync/notify.rs:22
// we must hold the lock. let waiters = notify.waiters.lock(); // Safety: called while locked let w = unsafe { &mut *waiter.get() }; if w.notified.is_some() { // Our waker has been notified. Reset the fields and ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
0d4d3c34f16383b155332460a7a96ef7ca681634
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0d4d3c34f16383b155332460a7a96ef7ca681634/tokio/src/sync/notify.rs
841
900
tokio-rs/tokio:tokio/src/sync/notify.rs:23
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 State::*; // Safety: The type only transitions to a "Waiting" state...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
0d4d3c34f16383b155332460a7a96ef7ca681634
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0d4d3c34f16383b155332460a7a96ef7ca681634/tokio/src/sync/notify.rs
881
940
tokio-rs/tokio:tokio/src/sync/notify.rs:24
unsafe { (*waiter.get()).notified }, Some(NotificationType::OneWaiter) ) { if let Some(waker) = notify_locked(&mut waiters, &notify.state, notify_state) { drop(waiters); waker.wake(); } } } } } /...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
0d4d3c34f16383b155332460a7a96ef7ca681634
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0d4d3c34f16383b155332460a7a96ef7ca681634/tokio/src/sync/notify.rs
921
953
tokio-rs/tokio:tokio/src/sync/notify.rs:13
/// let notified1 = notify.notified(); /// let notified2 = notify.notified(); /// /// let handle = tokio::spawn(async move { /// println!("sending notifications"); /// notify2.notify_waiters(); /// }); /// /// notified1.await; /// notified2.awa...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
46750870900e6ce52c70094894eb9860654bf70c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/46750870900e6ce52c70094894eb9860654bf70c/tokio/src/sync/notify.rs
481
540
tokio-rs/tokio:tokio/src/sync/notify.rs:22
// we must hold the lock. let waiters = notify.waiters.lock(); // Safety: called while locked let w = unsafe { &mut *waiter.get() }; if w.notified.is_some() { // Our waker has been notified. Reset the fields and ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
46750870900e6ce52c70094894eb9860654bf70c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/46750870900e6ce52c70094894eb9860654bf70c/tokio/src/sync/notify.rs
841
900
tokio-rs/tokio:tokio/src/sync/notify.rs:23
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 State::*; // Safety: The type only transitions to a "Waiting" state...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
46750870900e6ce52c70094894eb9860654bf70c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/46750870900e6ce52c70094894eb9860654bf70c/tokio/src/sync/notify.rs
881
940
tokio-rs/tokio:tokio/src/sync/notify.rs:24
// no concurrent access to the entry if let Some(NotificationType::OneWaiter) = unsafe { (*waiter.get()).notified } { if let Some(waker) = notify_locked(&mut waiters, &notify.state, notify_state) { drop(waiters); waker.wake(); } ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
46750870900e6ce52c70094894eb9860654bf70c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/46750870900e6ce52c70094894eb9860654bf70c/tokio/src/sync/notify.rs
921
952
tokio-rs/tokio:tokio/src/sync/notify.rs:3
/// struct Channel<T> { /// values: Mutex<VecDeque<T>>, /// notify: Notify, /// } /// /// impl<T> Channel<T> { /// pub fn send(&self, value: T) { /// self.values.lock().unwrap() /// .push_back(value); /// /// // Notify the consumer a value is available /// self.notify.not...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
1be8e9dfb7b1140568ac10ac34f5f8171a89e40d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1be8e9dfb7b1140568ac10ac34f5f8171a89e40d/tokio/src/sync/notify.rs
81
140
tokio-rs/tokio:tokio/src/sync/notify.rs:4
waiters: Mutex<WaitList>, } #[derive(Debug, Clone, Copy)] enum NotificationType { // Notification triggered by calling `notify_waiters` AllWaiters, // Notification triggered by calling `notify_one` OneWaiter, } #[derive(Debug)] #[repr(C)] // required by `linked_list::Link` impl struct Waiter { ///...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
1be8e9dfb7b1140568ac10ac34f5f8171a89e40d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1be8e9dfb7b1140568ac10ac34f5f8171a89e40d/tokio/src/sync/notify.rs
121
180
tokio-rs/tokio:tokio/src/sync/notify.rs:5
unsafe impl<'a> Send for Notified<'a> {} unsafe impl<'a> Sync for Notified<'a> {} #[derive(Debug)] enum State { Init(usize), Waiting, Done, } const NOTIFY_WAITERS_SHIFT: usize = 2; const STATE_MASK: usize = (1 << NOTIFY_WAITERS_SHIFT) - 1; const NOTIFY_WAITERS_CALLS_MASK: usize = !STATE_MASK; /// Initial...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
1be8e9dfb7b1140568ac10ac34f5f8171a89e40d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1be8e9dfb7b1140568ac10ac34f5f8171a89e40d/tokio/src/sync/notify.rs
161
220
tokio-rs/tokio:tokio/src/sync/notify.rs:6
data.fetch_add(1 << NOTIFY_WAITERS_SHIFT, SeqCst); } impl Notify { /// Create a new `Notify`, initialized without a permit. /// /// # Examples /// /// ``` /// use tokio::sync::Notify; /// /// let notify = Notify::new(); /// ``` pub fn new() -> Notify { Notify { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
1be8e9dfb7b1140568ac10ac34f5f8171a89e40d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1be8e9dfb7b1140568ac10ac34f5f8171a89e40d/tokio/src/sync/notify.rs
201
260
tokio-rs/tokio:tokio/src/sync/notify.rs:8
// we load the number of times notify_waiters // was called and store that in our initial state let state = self.state.load(SeqCst); Notified { notify: self, state: State::Init(state >> NOTIFY_WAITERS_SHIFT), waiter: UnsafeCell::new(Waiter { po...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
1be8e9dfb7b1140568ac10ac34f5f8171a89e40d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1be8e9dfb7b1140568ac10ac34f5f8171a89e40d/tokio/src/sync/notify.rs
281
340
tokio-rs/tokio:tokio/src/sync/notify.rs:9
/// tokio::spawn(async move { /// notify2.notified().await; /// println!("received notification"); /// }); /// /// println!("sending notification"); /// notify.notify_one(); /// } /// ``` // Alias for old name in 0.x #[cfg_attr(docsrs, doc(alias = ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
1be8e9dfb7b1140568ac10ac34f5f8171a89e40d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1be8e9dfb7b1140568ac10ac34f5f8171a89e40d/tokio/src/sync/notify.rs
321
380
tokio-rs/tokio:tokio/src/sync/notify.rs:10
drop(waiters); waker.wake(); } } /// Notifies all waiting tasks. /// /// If a task is currently waiting, that task is notified. Unlike with /// `notify_one()`, no permit is stored to be used by the next call to /// `notified().await`. The purpose of this method is to notify ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
1be8e9dfb7b1140568ac10ac34f5f8171a89e40d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1be8e9dfb7b1140568ac10ac34f5f8171a89e40d/tokio/src/sync/notify.rs
361
420
tokio-rs/tokio:tokio/src/sync/notify.rs:11
// 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 WAITING while the lock is held. let curr = self.state.load(SeqCst); if let EMPTY | NOT...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
1be8e9dfb7b1140568ac10ac34f5f8171a89e40d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1be8e9dfb7b1140568ac10ac34f5f8171a89e40d/tokio/src/sync/notify.rs
401
460
tokio-rs/tokio:tokio/src/sync/notify.rs:12
wakers.wake_all(); // Acquire the lock again. waiters = self.waiters.lock(); } // All waiters will be notified, the state must be transitioned to // `EMPTY`. As transitioning **from** `WAITING` requires the lock to be // held, a `store` is sufficient. le...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
1be8e9dfb7b1140568ac10ac34f5f8171a89e40d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1be8e9dfb7b1140568ac10ac34f5f8171a89e40d/tokio/src/sync/notify.rs
441
500
tokio-rs/tokio:tokio/src/sync/notify.rs:13
} WAITING => { // 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 mut waiter = ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
1be8e9dfb7b1140568ac10ac34f5f8171a89e40d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1be8e9dfb7b1140568ac10ac34f5f8171a89e40d/tokio/src/sync/notify.rs
481
540
tokio-rs/tokio:tokio/src/sync/notify.rs:14
is_unpin::<&Notify>(); is_unpin::<AtomicUsize>(); let me = self.get_unchecked_mut(); (me.notify, &mut me.state, &me.waiter) } } } impl Future for Notified<'_> { type Output = (); fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<()> { use Stat...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
1be8e9dfb7b1140568ac10ac34f5f8171a89e40d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1be8e9dfb7b1140568ac10ac34f5f8171a89e40d/tokio/src/sync/notify.rs
521
580
tokio-rs/tokio:tokio/src/sync/notify.rs:16
SeqCst, SeqCst, ); match res { Ok(_) => { // Acquired the notification *state = Done; ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
1be8e9dfb7b1140568ac10ac34f5f8171a89e40d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1be8e9dfb7b1140568ac10ac34f5f8171a89e40d/tokio/src/sync/notify.rs
601
660
tokio-rs/tokio:tokio/src/sync/notify.rs:17
let waiters = notify.waiters.lock(); // Safety: called while locked let w = unsafe { &mut *waiter.get() }; if w.notified.is_some() { // Our waker has been notified. Reset the fields and // remove it from the li...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
1be8e9dfb7b1140568ac10ac34f5f8171a89e40d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1be8e9dfb7b1140568ac10ac34f5f8171a89e40d/tokio/src/sync/notify.rs
641
700
tokio-rs/tokio:tokio/src/sync/notify.rs:18
// Safety: The type only transitions to a "Waiting" state when pinned. let (notify, state, waiter) = unsafe { Pin::new_unchecked(self).project() }; // This is where we ensure safety. The `Notified` value is being // dropped, which means we must ensure that the waiter entry is no // long...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
1be8e9dfb7b1140568ac10ac34f5f8171a89e40d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1be8e9dfb7b1140568ac10ac34f5f8171a89e40d/tokio/src/sync/notify.rs
681
740
tokio-rs/tokio:tokio/src/sync/notify.rs:19
/// /// `Waiter` is forced to be !Unpin. unsafe impl linked_list::Link for Waiter { 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 } u...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
1be8e9dfb7b1140568ac10ac34f5f8171a89e40d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1be8e9dfb7b1140568ac10ac34f5f8171a89e40d/tokio/src/sync/notify.rs
721
740
tokio-rs/tokio:tokio/src/sync/notify.rs:3
/// struct Channel<T> { /// values: Mutex<VecDeque<T>>, /// notify: Notify, /// } /// /// impl<T> Channel<T> { /// pub fn send(&self, value: T) { /// self.values.lock().unwrap() /// .push_back(value); /// /// // Notify the consumer a value is available /// self.notify.not...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
1265d0c5dcf0f0c46430ef9f26710aac952c545e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1265d0c5dcf0f0c46430ef9f26710aac952c545e/tokio/src/sync/notify.rs
81
140
tokio-rs/tokio:tokio/src/sync/notify.rs:4
waiters: Mutex<WaitList>, } #[derive(Debug, Clone, Copy)] enum NotificationType { // Notification triggered by calling `notify_waiters` AllWaiters, // Notification triggered by calling `notify_one` OneWaiter, } #[derive(Debug)] struct Waiter { /// Intrusive linked-list pointers. pointers: link...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
1265d0c5dcf0f0c46430ef9f26710aac952c545e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1265d0c5dcf0f0c46430ef9f26710aac952c545e/tokio/src/sync/notify.rs
121
180
tokio-rs/tokio:tokio/src/sync/notify.rs:5
unsafe impl<'a> Sync for Notified<'a> {} #[derive(Debug)] enum State { Init(usize), Waiting, Done, } const NOTIFY_WAITERS_SHIFT: usize = 2; const STATE_MASK: usize = (1 << NOTIFY_WAITERS_SHIFT) - 1; const NOTIFY_WAITERS_CALLS_MASK: usize = !STATE_MASK; /// Initial "idle" state. const EMPTY: usize = 0; /...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
1265d0c5dcf0f0c46430ef9f26710aac952c545e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1265d0c5dcf0f0c46430ef9f26710aac952c545e/tokio/src/sync/notify.rs
161
220
tokio-rs/tokio:tokio/src/sync/notify.rs:6
} impl Notify { /// Create a new `Notify`, initialized without a permit. /// /// # Examples /// /// ``` /// use tokio::sync::Notify; /// /// let notify = Notify::new(); /// ``` pub fn new() -> Notify { Notify { state: AtomicUsize::new(0), waiters:...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
1265d0c5dcf0f0c46430ef9f26710aac952c545e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1265d0c5dcf0f0c46430ef9f26710aac952c545e/tokio/src/sync/notify.rs
201
260
tokio-rs/tokio:tokio/src/sync/notify.rs:8
// was called and store that in our initial state let state = self.state.load(SeqCst); Notified { notify: self, state: State::Init(state >> NOTIFY_WAITERS_SHIFT), waiter: UnsafeCell::new(Waiter { pointers: linked_list::Pointers::new(), ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
1265d0c5dcf0f0c46430ef9f26710aac952c545e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1265d0c5dcf0f0c46430ef9f26710aac952c545e/tokio/src/sync/notify.rs
281
340
tokio-rs/tokio:tokio/src/sync/notify.rs:9
/// notify2.notified().await; /// println!("received notification"); /// }); /// /// println!("sending notification"); /// notify.notify_one(); /// } /// ``` // Alias for old name in 0.x #[cfg_attr(docsrs, doc(alias = "notify"))] pub fn notify_one(&sel...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
1265d0c5dcf0f0c46430ef9f26710aac952c545e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1265d0c5dcf0f0c46430ef9f26710aac952c545e/tokio/src/sync/notify.rs
321
380
tokio-rs/tokio:tokio/src/sync/notify.rs:10
waker.wake(); } } /// Notifies all waiting tasks. /// /// If a task is currently waiting, that task is notified. Unlike with /// `notify_one()`, no permit is stored to be used by the next call to /// `notified().await`. The purpose of this method is to notify all /// already registe...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
1265d0c5dcf0f0c46430ef9f26710aac952c545e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1265d0c5dcf0f0c46430ef9f26710aac952c545e/tokio/src/sync/notify.rs
361
420
tokio-rs/tokio:tokio/src/sync/notify.rs:11
let mut waiters = self.waiters.lock(); // The state must be reloaded while the lock is held. The state may only // transition out of WAITING while the lock is held. let curr = self.state.load(SeqCst); if let EMPTY | NOTIFIED = get_state(curr) { // There are no waiting tasks...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
1265d0c5dcf0f0c46430ef9f26710aac952c545e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1265d0c5dcf0f0c46430ef9f26710aac952c545e/tokio/src/sync/notify.rs
401
460
tokio-rs/tokio:tokio/src/sync/notify.rs:12
// Acquire the lock again. waiters = self.waiters.lock(); } // All waiters will be notified, the state must be transitioned to // `EMPTY`. As transitioning **from** `WAITING` requires the lock to be // held, a `store` is sufficient. let new = set_state(inc_num_notify...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
1265d0c5dcf0f0c46430ef9f26710aac952c545e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1265d0c5dcf0f0c46430ef9f26710aac952c545e/tokio/src/sync/notify.rs
441
500
tokio-rs/tokio:tokio/src/sync/notify.rs:13
WAITING => { // 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 mut waiter = waiters.pop_ba...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
1265d0c5dcf0f0c46430ef9f26710aac952c545e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1265d0c5dcf0f0c46430ef9f26710aac952c545e/tokio/src/sync/notify.rs
481
540
tokio-rs/tokio:tokio/src/sync/notify.rs:14
is_unpin::<&Notify>(); is_unpin::<AtomicUsize>(); let me = self.get_unchecked_mut(); (me.notify, &mut me.state, &me.waiter) } } } impl Future for Notified<'_> { type Output = (); fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<()> { use Stat...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
1265d0c5dcf0f0c46430ef9f26710aac952c545e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1265d0c5dcf0f0c46430ef9f26710aac952c545e/tokio/src/sync/notify.rs
521
580
tokio-rs/tokio:tokio/src/sync/notify.rs:15
// Acquire the lock and attempt to transition to the waiting // state. let mut waiters = notify.waiters.lock(); // Reload the state with the lock held let mut curr = notify.state.load(SeqCst); // if notify_waiters has ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
1265d0c5dcf0f0c46430ef9f26710aac952c545e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1265d0c5dcf0f0c46430ef9f26710aac952c545e/tokio/src/sync/notify.rs
561
620
tokio-rs/tokio:tokio/src/sync/notify.rs:16
SeqCst, ); match res { Ok(_) => { // Acquired the notification *state = Done; return Poll::Ready(()...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
1265d0c5dcf0f0c46430ef9f26710aac952c545e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1265d0c5dcf0f0c46430ef9f26710aac952c545e/tokio/src/sync/notify.rs
601
660
tokio-rs/tokio:tokio/src/sync/notify.rs:17
// Safety: called while locked let w = unsafe { &mut *waiter.get() }; if w.notified.is_some() { // Our waker has been notified. Reset the fields and // remove it from the list. w.waker = None; ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
1265d0c5dcf0f0c46430ef9f26710aac952c545e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1265d0c5dcf0f0c46430ef9f26710aac952c545e/tokio/src/sync/notify.rs
641
700
tokio-rs/tokio:tokio/src/sync/notify.rs:18
let (notify, state, waiter) = unsafe { Pin::new_unchecked(self).project() }; // 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 let Waiting = *state { let...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
1265d0c5dcf0f0c46430ef9f26710aac952c545e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1265d0c5dcf0f0c46430ef9f26710aac952c545e/tokio/src/sync/notify.rs
681
739
tokio-rs/tokio:tokio/src/sync/notify.rs:19
/// `Waiter` is forced to be !Unpin. unsafe impl linked_list::Link for Waiter { 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 } unsaf...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
1265d0c5dcf0f0c46430ef9f26710aac952c545e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1265d0c5dcf0f0c46430ef9f26710aac952c545e/tokio/src/sync/notify.rs
721
739
tokio-rs/tokio:tokio/src/sync/notify.rs:3
/// } /// /// impl<T> Channel<T> { /// pub fn send(&self, value: T) { /// self.values.lock().unwrap() /// .push_back(value); /// /// // Notify the consumer a value is available /// self.notify.notify_one(); /// } /// /// pub async fn recv(&self) -> T { /// loop { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
03969cdae7674681d1b10926e6a56fbb8908dbb8
github
async-runtime
https://github.com/tokio-rs/tokio/blob/03969cdae7674681d1b10926e6a56fbb8908dbb8/tokio/src/sync/notify.rs
81
140
tokio-rs/tokio:tokio/src/sync/notify.rs:4
#[derive(Debug, Clone, Copy)] enum NotificationType { // Notification triggered by calling `notify_waiters` AllWaiters, // Notification triggered by calling `notify_one` OneWaiter, } #[derive(Debug)] struct Waiter { /// Intrusive linked-list pointers. pointers: linked_list::Pointers<Waiter>, ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
03969cdae7674681d1b10926e6a56fbb8908dbb8
github
async-runtime
https://github.com/tokio-rs/tokio/blob/03969cdae7674681d1b10926e6a56fbb8908dbb8/tokio/src/sync/notify.rs
121
180
tokio-rs/tokio:tokio/src/sync/notify.rs:5
enum State { Init(usize), Waiting, Done, } const NOTIFY_WAITERS_SHIFT: usize = 2; const STATE_MASK: usize = (1 << NOTIFY_WAITERS_SHIFT) - 1; const NOTIFY_WAITERS_CALLS_MASK: usize = !STATE_MASK; /// Initial "idle" state. const EMPTY: usize = 0; /// One or more threads are currently waiting to be notified...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
03969cdae7674681d1b10926e6a56fbb8908dbb8
github
async-runtime
https://github.com/tokio-rs/tokio/blob/03969cdae7674681d1b10926e6a56fbb8908dbb8/tokio/src/sync/notify.rs
161
220
tokio-rs/tokio:tokio/src/sync/notify.rs:6
/// Create a new `Notify`, initialized without a permit. /// /// # Examples /// /// ``` /// use tokio::sync::Notify; /// /// let notify = Notify::new(); /// ``` pub fn new() -> Notify { Notify { state: AtomicUsize::new(0), waiters: Mutex::new(LinkedLis...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
03969cdae7674681d1b10926e6a56fbb8908dbb8
github
async-runtime
https://github.com/tokio-rs/tokio/blob/03969cdae7674681d1b10926e6a56fbb8908dbb8/tokio/src/sync/notify.rs
201
260
tokio-rs/tokio:tokio/src/sync/notify.rs:8
notify: self, state: State::Init(state >> NOTIFY_WAITERS_SHIFT), waiter: UnsafeCell::new(Waiter { pointers: linked_list::Pointers::new(), waker: None, notified: None, _p: PhantomPinned, }), } } /// Notif...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
03969cdae7674681d1b10926e6a56fbb8908dbb8
github
async-runtime
https://github.com/tokio-rs/tokio/blob/03969cdae7674681d1b10926e6a56fbb8908dbb8/tokio/src/sync/notify.rs
281
340
tokio-rs/tokio:tokio/src/sync/notify.rs:9
/// /// println!("sending notification"); /// notify.notify_one(); /// } /// ``` // Alias for old name in 0.x #[cfg_attr(docsrs, doc(alias = "notify"))] pub fn notify_one(&self) { // Load the current state let mut curr = self.state.load(SeqCst); // If the sta...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
03969cdae7674681d1b10926e6a56fbb8908dbb8
github
async-runtime
https://github.com/tokio-rs/tokio/blob/03969cdae7674681d1b10926e6a56fbb8908dbb8/tokio/src/sync/notify.rs
321
380
tokio-rs/tokio:tokio/src/sync/notify.rs:10
/// Notifies all waiting tasks. /// /// If a task is currently waiting, that task is notified. Unlike with /// `notify_one()`, no permit is stored to be used by the next call to /// `notified().await`. The purpose of this method is to notify all /// already registered waiters. Registering for notifi...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
03969cdae7674681d1b10926e6a56fbb8908dbb8
github
async-runtime
https://github.com/tokio-rs/tokio/blob/03969cdae7674681d1b10926e6a56fbb8908dbb8/tokio/src/sync/notify.rs
361
420
tokio-rs/tokio:tokio/src/sync/notify.rs:11
// transition out of WAITING while the lock is held. let curr = self.state.load(SeqCst); if let EMPTY | NOTIFIED = get_state(curr) { // There are no waiting tasks. All we need to do is increment the // number of times this method was called. atomic_inc_num_notify_wai...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
03969cdae7674681d1b10926e6a56fbb8908dbb8
github
async-runtime
https://github.com/tokio-rs/tokio/blob/03969cdae7674681d1b10926e6a56fbb8908dbb8/tokio/src/sync/notify.rs
401
460
tokio-rs/tokio:tokio/src/sync/notify.rs:12
} // All waiters will be notified, the state must be transitioned to // `EMPTY`. As transitioning **from** `WAITING` requires the lock to be // held, a `store` is sufficient. let new = set_state(inc_num_notify_waiters_calls(curr), EMPTY); self.state.store(new, SeqCst); ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
03969cdae7674681d1b10926e6a56fbb8908dbb8
github
async-runtime
https://github.com/tokio-rs/tokio/blob/03969cdae7674681d1b10926e6a56fbb8908dbb8/tokio/src/sync/notify.rs
441
500
tokio-rs/tokio:tokio/src/sync/notify.rs:13
// transition **out** of `WAITING`. // // Get a pending waiter let mut waiter = waiters.pop_back().unwrap(); // Safety: `waiters` lock is still held. let waiter = unsafe { waiter.as_mut() }; assert!(waiter.notified.is_none...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
03969cdae7674681d1b10926e6a56fbb8908dbb8
github
async-runtime
https://github.com/tokio-rs/tokio/blob/03969cdae7674681d1b10926e6a56fbb8908dbb8/tokio/src/sync/notify.rs
481
540