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:3
/// self.notify.notify_one(); /// } /// /// pub async fn recv(&self) -> T { /// loop { /// // Drain values /// if let Some(value) = self.values.lock().unwrap().pop_front() { /// return value; /// } /// /// // Wait for values to be a...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
e7091fde786722a5301270e6281fc3c449dcfc14
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e7091fde786722a5301270e6281fc3c449dcfc14/tokio/src/sync/notify.rs
81
140
tokio-rs/tokio:tokio/src/sync/notify.rs:4
/// Waiting task's waker waker: Option<Waker>, /// `true` if the notification has been assigned to this waiter. notified: Option<NotificationType>, /// Should not be `Unpin`. _p: PhantomPinned, } /// Future returned from `notified()` #[derive(Debug)] pub struct Notified<'a> { /// The `Notify`...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
e7091fde786722a5301270e6281fc3c449dcfc14
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e7091fde786722a5301270e6281fc3c449dcfc14/tokio/src/sync/notify.rs
121
180
tokio-rs/tokio:tokio/src/sync/notify.rs:5
/// Pending notification const NOTIFIED: u8 = 2; impl Notify { /// Create a new `Notify`, initialized without a permit. /// /// # Examples /// /// ``` /// use tokio::sync::Notify; /// /// let notify = Notify::new(); /// ``` pub fn new() -> Notify { Notify { s...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
e7091fde786722a5301270e6281fc3c449dcfc14
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e7091fde786722a5301270e6281fc3c449dcfc14/tokio/src/sync/notify.rs
161
220
tokio-rs/tokio:tokio/src/sync/notify.rs:7
notified: None, _p: PhantomPinned, }), } } /// 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 imme...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
e7091fde786722a5301270e6281fc3c449dcfc14
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e7091fde786722a5301270e6281fc3c449dcfc14/tokio/src/sync/notify.rs
241
300
tokio-rs/tokio:tokio/src/sync/notify.rs:8
pub fn notify_one(&self) { // 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 = curr { // The compare-exchange from `NOTIFIED` -> `NOTIFIED` is intended. A ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
e7091fde786722a5301270e6281fc3c449dcfc14
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e7091fde786722a5301270e6281fc3c449dcfc14/tokio/src/sync/notify.rs
281
340
tokio-rs/tokio:tokio/src/sync/notify.rs:9
let curr = self.state.load(SeqCst); if let EMPTY | NOTIFIED = curr { // There are no waiting tasks. In this case, no synchronization is // established between `notify` and `notified().await`. return; } // At this point, it is guaranteed that the state will n...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
e7091fde786722a5301270e6281fc3c449dcfc14
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e7091fde786722a5301270e6281fc3c449dcfc14/tokio/src/sync/notify.rs
321
380
tokio-rs/tokio:tokio/src/sync/notify.rs:10
loop { match curr { EMPTY | NOTIFIED => { let res = state.compare_exchange(curr, NOTIFIED, SeqCst, SeqCst); match res { Ok(_) => return None, Err(actual) => { assert!(actual == EMPTY || actual == NOTIFIE...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
e7091fde786722a5301270e6281fc3c449dcfc14
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e7091fde786722a5301270e6281fc3c449dcfc14/tokio/src/sync/notify.rs
361
420
tokio-rs/tokio:tokio/src/sync/notify.rs:11
_ => unreachable!(), } } } // ===== impl Notified ===== impl Notified<'_> { /// A custom `project` implementation is used in place of `pin-project-lite` /// as a custom drop implementation is needed. fn project(self: Pin<&mut Self>) -> (&Notify, &mut State, &UnsafeCell<Waiter>) { unsaf...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
e7091fde786722a5301270e6281fc3c449dcfc14
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e7091fde786722a5301270e6281fc3c449dcfc14/tokio/src/sync/notify.rs
401
460
tokio-rs/tokio:tokio/src/sync/notify.rs:12
// Acquired the notification *state = Done; return Poll::Ready(()); } // Acquire the lock and attempt to transition to the waiting // state. let mut waiters = notify.waiters.lock().unwrap(); ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
e7091fde786722a5301270e6281fc3c449dcfc14
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e7091fde786722a5301270e6281fc3c449dcfc14/tokio/src/sync/notify.rs
441
500
tokio-rs/tokio:tokio/src/sync/notify.rs:13
} Err(actual) => { assert_eq!(actual, EMPTY); curr = actual; } } } _ => unreacha...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
e7091fde786722a5301270e6281fc3c449dcfc14
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e7091fde786722a5301270e6281fc3c449dcfc14/tokio/src/sync/notify.rs
481
540
tokio-rs/tokio:tokio/src/sync/notify.rs:14
w.notified = None; *state = Done; } else { // Update the waker, if necessary. if !w.waker.as_ref().unwrap().will_wake(cx.waker()) { w.waker = Some(cx.waker().clone()); } ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
e7091fde786722a5301270e6281fc3c449dcfc14
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e7091fde786722a5301270e6281fc3c449dcfc14/tokio/src/sync/notify.rs
521
580
tokio-rs/tokio:tokio/src/sync/notify.rs:15
// `Notify.state` may be in any of the three states (Empty, Waiting, // Notified). It doesn't actually matter what the atomic is set to // at this point. We hold the lock and will ensure the atomic is in // the correct state once the lock is dropped. // // Bec...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
e7091fde786722a5301270e6281fc3c449dcfc14
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e7091fde786722a5301270e6281fc3c449dcfc14/tokio/src/sync/notify.rs
561
620
tokio-rs/tokio:tokio/src/sync/notify.rs:3
/// self.notify.notify_one(); /// } /// /// pub async fn recv(&self) -> T { /// loop { /// // Drain values /// if let Some(value) = self.values.lock().unwrap().pop_front() { /// return value; /// } /// /// // Wait for values to be a...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
8d2e3bc575f51815ae7319f1e43fe6c7d664e6e4
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8d2e3bc575f51815ae7319f1e43fe6c7d664e6e4/tokio/src/sync/notify.rs
81
140
tokio-rs/tokio:tokio/src/sync/notify.rs:4
_p: PhantomPinned, } /// Future returned from `notified()` #[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 waiter `LinkedList`. waiter: UnsafeCell<Waiter>, } unsa...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
8d2e3bc575f51815ae7319f1e43fe6c7d664e6e4
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8d2e3bc575f51815ae7319f1e43fe6c7d664e6e4/tokio/src/sync/notify.rs
121
180
tokio-rs/tokio:tokio/src/sync/notify.rs:5
/// ``` /// use tokio::sync::Notify; /// /// let notify = Notify::new(); /// ``` pub fn new() -> Notify { Notify { state: AtomicU8::new(0), waiters: Mutex::new(LinkedList::new()), } } /// Create a new `Notify`, initialized without a permit. /// ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
8d2e3bc575f51815ae7319f1e43fe6c7d664e6e4
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8d2e3bc575f51815ae7319f1e43fe6c7d664e6e4/tokio/src/sync/notify.rs
161
220
tokio-rs/tokio:tokio/src/sync/notify.rs:7
/// 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
8d2e3bc575f51815ae7319f1e43fe6c7d664e6e4
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8d2e3bc575f51815ae7319f1e43fe6c7d664e6e4/tokio/src/sync/notify.rs
241
300
tokio-rs/tokio:tokio/src/sync/notify.rs:8
// operation and a task calling `notified().await`. let res = self.state.compare_exchange(curr, NOTIFIED, 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
8d2e3bc575f51815ae7319f1e43fe6c7d664e6e4
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8d2e3bc575f51815ae7319f1e43fe6c7d664e6e4/tokio/src/sync/notify.rs
281
340
tokio-rs/tokio:tokio/src/sync/notify.rs:9
// 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 pending waiters while let Some(mut waiter) = waiters.pop_back() { // Safety: `waiters` lock is still hel...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
8d2e3bc575f51815ae7319f1e43fe6c7d664e6e4
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8d2e3bc575f51815ae7319f1e43fe6c7d664e6e4/tokio/src/sync/notify.rs
321
380
tokio-rs/tokio:tokio/src/sync/notify.rs:10
assert!(actual == EMPTY || actual == NOTIFIED); state.store(NOTIFIED, SeqCst); return None; } } } WAITING => { // At this point, it is guaranteed that the state will not // concurr...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
8d2e3bc575f51815ae7319f1e43fe6c7d664e6e4
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8d2e3bc575f51815ae7319f1e43fe6c7d664e6e4/tokio/src/sync/notify.rs
361
420
tokio-rs/tokio:tokio/src/sync/notify.rs:11
/// A custom `project` implementation is used in place of `pin-project-lite` /// 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::<&Not...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
8d2e3bc575f51815ae7319f1e43fe6c7d664e6e4
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8d2e3bc575f51815ae7319f1e43fe6c7d664e6e4/tokio/src/sync/notify.rs
401
460
tokio-rs/tokio:tokio/src/sync/notify.rs:12
// Reload the state with the lock held let mut curr = notify.state.load(SeqCst); // Transition the state to WAITING. loop { match curr { EMPTY => { // Transition to WAITING ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
8d2e3bc575f51815ae7319f1e43fe6c7d664e6e4
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8d2e3bc575f51815ae7319f1e43fe6c7d664e6e4/tokio/src/sync/notify.rs
441
500
tokio-rs/tokio:tokio/src/sync/notify.rs:13
} } // Safety: called while locked. unsafe { (*waiter.get()).waker = Some(cx.waker().clone()); } // Insert the waiter into the linked list // // safety: p...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
8d2e3bc575f51815ae7319f1e43fe6c7d664e6e4
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8d2e3bc575f51815ae7319f1e43fe6c7d664e6e4/tokio/src/sync/notify.rs
481
540
tokio-rs/tokio:tokio/src/sync/notify.rs:14
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
8d2e3bc575f51815ae7319f1e43fe6c7d664e6e4
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8d2e3bc575f51815ae7319f1e43fe6c7d664e6e4/tokio/src/sync/notify.rs
521
580
tokio-rs/tokio:tokio/src/sync/notify.rs:15
// receiver is notified but has not yet observed the notification. // If this happens, no matter how many notifications happen between // this receiver being notified and the receive future dropping, all // we need to do is ensure that one notification is returned back to ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
8d2e3bc575f51815ae7319f1e43fe6c7d664e6e4
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8d2e3bc575f51815ae7319f1e43fe6c7d664e6e4/tokio/src/sync/notify.rs
561
620
tokio-rs/tokio:tokio/src/sync/notify.rs:4
_p: PhantomPinned, } /// Future returned from `notified()` #[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 waiter `LinkedList`. waiter: UnsafeCell<Waiter>, } unsa...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
2bc9a4815259c8ff4daa5e24f128ec826970d17f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2bc9a4815259c8ff4daa5e24f128ec826970d17f/tokio/src/sync/notify.rs
121
180
tokio-rs/tokio:tokio/src/sync/notify.rs:5
/// ``` /// use tokio::sync::Notify; /// /// let notify = Notify::new(); /// ``` pub fn new() -> Notify { Notify { state: AtomicU8::new(0), waiters: Mutex::new(LinkedList::new()), } } /// Wait for a notification. /// /// Equivalent to: ///...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
2bc9a4815259c8ff4daa5e24f128ec826970d17f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2bc9a4815259c8ff4daa5e24f128ec826970d17f/tokio/src/sync/notify.rs
161
220
tokio-rs/tokio:tokio/src/sync/notify.rs:6
/// println!("received notification"); /// }); /// /// println!("sending notification"); /// notify.notify_one(); /// } /// ``` pub fn notified(&self) -> Notified<'_> { Notified { notify: self, state: State::Init, waiter: Unsafe...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
2bc9a4815259c8ff4daa5e24f128ec826970d17f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2bc9a4815259c8ff4daa5e24f128ec826970d17f/tokio/src/sync/notify.rs
201
260
tokio-rs/tokio:tokio/src/sync/notify.rs:7
/// #[tokio::main] /// async fn main() { /// let notify = Arc::new(Notify::new()); /// let notify2 = notify.clone(); /// /// tokio::spawn(async move { /// notify2.notified().await; /// println!("received notification"); /// }); /// /// println!...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
2bc9a4815259c8ff4daa5e24f128ec826970d17f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2bc9a4815259c8ff4daa5e24f128ec826970d17f/tokio/src/sync/notify.rs
241
300
tokio-rs/tokio:tokio/src/sync/notify.rs:8
if let Some(waker) = notify_locked(&mut waiters, &self.state, curr) { drop(waiters); waker.wake(); } } /// Notifies all waiting tasks pub(crate) fn notify_waiters(&self) { // There are waiters, the lock must be acquired to notify. let mut waiters = self.waite...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
2bc9a4815259c8ff4daa5e24f128ec826970d17f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2bc9a4815259c8ff4daa5e24f128ec826970d17f/tokio/src/sync/notify.rs
281
340
tokio-rs/tokio:tokio/src/sync/notify.rs:9
// All waiters have been notified, the state must be transitioned to // `EMPTY`. As transitioning **from** `WAITING` requires the lock to be // held, a `store` is sufficient. self.state.store(EMPTY, SeqCst); } } impl Default for Notify { fn default() -> Notify { Notify::new() ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
2bc9a4815259c8ff4daa5e24f128ec826970d17f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2bc9a4815259c8ff4daa5e24f128ec826970d17f/tokio/src/sync/notify.rs
321
380
tokio-rs/tokio:tokio/src/sync/notify.rs:10
waiter.notified = true; let waker = waiter.waker.take(); if waiters.is_empty() { // As this the **final** waiter in the list, the state // must be transitioned to `EMPTY`. As transitioning // **from** `WAITING` requires the loc...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
2bc9a4815259c8ff4daa5e24f128ec826970d17f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2bc9a4815259c8ff4daa5e24f128ec826970d17f/tokio/src/sync/notify.rs
361
420
tokio-rs/tokio:tokio/src/sync/notify.rs:11
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<()> { use State::*; let (notify, state, waiter) = self.project(); loop { match *state { Init => { // Optimistically try acquiring a pending notification let res = not...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
2bc9a4815259c8ff4daa5e24f128ec826970d17f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2bc9a4815259c8ff4daa5e24f128ec826970d17f/tokio/src/sync/notify.rs
401
460
tokio-rs/tokio:tokio/src/sync/notify.rs:12
} } WAITING => break, NOTIFIED => { // Try consuming the notification let res = notify .state .compa...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
2bc9a4815259c8ff4daa5e24f128ec826970d17f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2bc9a4815259c8ff4daa5e24f128ec826970d17f/tokio/src/sync/notify.rs
441
500
tokio-rs/tokio:tokio/src/sync/notify.rs:13
// 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, // we must hold the lock. let waiters = notify.waiters.lock().unwrap(...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
2bc9a4815259c8ff4daa5e24f128ec826970d17f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2bc9a4815259c8ff4daa5e24f128ec826970d17f/tokio/src/sync/notify.rs
481
540
tokio-rs/tokio:tokio/src/sync/notify.rs:14
impl Drop for Notified<'_> { fn drop(&mut self) { use State::*; // 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 ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
2bc9a4815259c8ff4daa5e24f128ec826970d17f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2bc9a4815259c8ff4daa5e24f128ec826970d17f/tokio/src/sync/notify.rs
521
580
tokio-rs/tokio:tokio/src/sync/notify.rs:15
// observes the incorrect `EMPTY` state, it will then obtain the // lock and block until `notify.state` is in the correct final // state. notify.state.store(EMPTY, SeqCst); } // See if the node was notified but not received. In this case, the ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
2bc9a4815259c8ff4daa5e24f128ec826970d17f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2bc9a4815259c8ff4daa5e24f128ec826970d17f/tokio/src/sync/notify.rs
561
604
tokio-rs/tokio:tokio/src/sync/notify.rs:3
/// self.notify.notify_one(); /// } /// /// pub async fn recv(&self) -> T { /// loop { /// // Drain values /// if let Some(value) = self.values.lock().unwrap().pop_front() { /// return value; /// } /// /// // Wait for values to be a...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
38ec4845d14c25b9d89cb6fbdf2a5c5472971fc3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/38ec4845d14c25b9d89cb6fbdf2a5c5472971fc3/tokio/src/sync/notify.rs
81
140
tokio-rs/tokio:tokio/src/sync/notify.rs:4
_p: PhantomPinned, } /// Future returned from `notified()` #[derive(Debug)] struct Notified<'a> { /// The `Notify` being received on. notify: &'a Notify, /// The current state of the receiving process. state: State, /// Entry in the waiter `LinkedList`. waiter: UnsafeCell<Waiter>, } unsafe i...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
38ec4845d14c25b9d89cb6fbdf2a5c5472971fc3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/38ec4845d14c25b9d89cb6fbdf2a5c5472971fc3/tokio/src/sync/notify.rs
121
180
tokio-rs/tokio:tokio/src/sync/notify.rs:5
/// ``` /// use tokio::sync::Notify; /// /// let notify = Notify::new(); /// ``` pub fn new() -> Notify { Notify { state: AtomicU8::new(0), waiters: Mutex::new(LinkedList::new()), } } /// Wait for a notification. /// /// Each `Notify` value ho...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
38ec4845d14c25b9d89cb6fbdf2a5c5472971fc3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/38ec4845d14c25b9d89cb6fbdf2a5c5472971fc3/tokio/src/sync/notify.rs
161
220
tokio-rs/tokio:tokio/src/sync/notify.rs:6
/// ``` pub async fn notified(&self) { Notified { notify: self, state: State::Init, waiter: UnsafeCell::new(Waiter { pointers: linked_list::Pointers::new(), waker: None, notified: false, _p: PhantomPinned, ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
38ec4845d14c25b9d89cb6fbdf2a5c5472971fc3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/38ec4845d14c25b9d89cb6fbdf2a5c5472971fc3/tokio/src/sync/notify.rs
201
260
tokio-rs/tokio:tokio/src/sync/notify.rs:7
/// tokio::spawn(async move { /// notify2.notified().await; /// println!("received notification"); /// }); /// /// println!("sending notification"); /// notify.notify_one(); /// } /// ``` pub fn notify_one(&self) { // Load the current state ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
38ec4845d14c25b9d89cb6fbdf2a5c5472971fc3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/38ec4845d14c25b9d89cb6fbdf2a5c5472971fc3/tokio/src/sync/notify.rs
241
300
tokio-rs/tokio:tokio/src/sync/notify.rs:8
} } impl Default for Notify { fn default() -> Notify { Notify::new() } } fn notify_locked(waiters: &mut WaitList, state: &AtomicU8, curr: u8) -> Option<Waker> { loop { match curr { EMPTY | NOTIFIED => { let res = state.compare_exchange(curr, NOTIFIED, SeqCst, Se...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
38ec4845d14c25b9d89cb6fbdf2a5c5472971fc3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/38ec4845d14c25b9d89cb6fbdf2a5c5472971fc3/tokio/src/sync/notify.rs
281
340
tokio-rs/tokio:tokio/src/sync/notify.rs:9
if waiters.is_empty() { // As this the **final** waiter in the list, the state // must be transitioned to `EMPTY`. As transitioning // **from** `WAITING` requires the lock to be held, a // `store` is sufficient. state.st...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
38ec4845d14c25b9d89cb6fbdf2a5c5472971fc3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/38ec4845d14c25b9d89cb6fbdf2a5c5472971fc3/tokio/src/sync/notify.rs
321
380
tokio-rs/tokio:tokio/src/sync/notify.rs:10
loop { match *state { Init => { // Optimistically try acquiring a pending notification let res = notify .state .compare_exchange(NOTIFIED, EMPTY, SeqCst, SeqCst); if res.is_ok() { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
38ec4845d14c25b9d89cb6fbdf2a5c5472971fc3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/38ec4845d14c25b9d89cb6fbdf2a5c5472971fc3/tokio/src/sync/notify.rs
361
420
tokio-rs/tokio:tokio/src/sync/notify.rs:11
// Try consuming the notification let res = notify .state .compare_exchange(NOTIFIED, EMPTY, SeqCst, SeqCst); match res { Ok(_) => { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
38ec4845d14c25b9d89cb6fbdf2a5c5472971fc3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/38ec4845d14c25b9d89cb6fbdf2a5c5472971fc3/tokio/src/sync/notify.rs
401
460
tokio-rs/tokio:tokio/src/sync/notify.rs:12
// Safety: called while locked let w = unsafe { &mut *waiter.get() }; if w.notified { // 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
38ec4845d14c25b9d89cb6fbdf2a5c5472971fc3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/38ec4845d14c25b9d89cb6fbdf2a5c5472971fc3/tokio/src/sync/notify.rs
441
500
tokio-rs/tokio:tokio/src/sync/notify.rs:13
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
38ec4845d14c25b9d89cb6fbdf2a5c5472971fc3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/38ec4845d14c25b9d89cb6fbdf2a5c5472971fc3/tokio/src/sync/notify.rs
481
540
tokio-rs/tokio:tokio/src/sync/notify.rs:14
// See if the node was notified but not received. In this case, the // notification must be sent to another waiter. // // Safety: with the entry removed from the linked list, there can be // no concurrent access to the entry let notified = unsafe { (*waiter.ge...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
38ec4845d14c25b9d89cb6fbdf2a5c5472971fc3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/38ec4845d14c25b9d89cb6fbdf2a5c5472971fc3/tokio/src/sync/notify.rs
521
558
tokio-rs/tokio:tokio/src/sync/notify.rs:3
/// self.notify.notify(); /// } /// /// pub async fn recv(&self) -> T { /// loop { /// // Drain values /// if let Some(value) = self.values.lock().unwrap().pop_front() { /// return value; /// } /// /// // Wait for values to be avail...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
c9f5bc29158a6f3a786e9d67df8da31524e8a9c3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c9f5bc29158a6f3a786e9d67df8da31524e8a9c3/tokio/src/sync/notify.rs
81
140
tokio-rs/tokio:tokio/src/sync/notify.rs:4
_p: PhantomPinned, } /// Future returned from `notified()` #[derive(Debug)] struct Notified<'a> { /// The `Notify` being received on. notify: &'a Notify, /// The current state of the receiving process. state: State, /// Entry in the waiter `LinkedList`. waiter: UnsafeCell<Waiter>, } unsafe i...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
c9f5bc29158a6f3a786e9d67df8da31524e8a9c3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c9f5bc29158a6f3a786e9d67df8da31524e8a9c3/tokio/src/sync/notify.rs
121
180
tokio-rs/tokio:tokio/src/sync/notify.rs:5
/// ``` /// use tokio::sync::Notify; /// /// let notify = Notify::new(); /// ``` pub fn new() -> Notify { Notify { state: AtomicU8::new(0), waiters: Mutex::new(LinkedList::new()), } } /// Wait for a notification. /// /// Each `Notify` value ho...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
c9f5bc29158a6f3a786e9d67df8da31524e8a9c3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c9f5bc29158a6f3a786e9d67df8da31524e8a9c3/tokio/src/sync/notify.rs
161
220
tokio-rs/tokio:tokio/src/sync/notify.rs:6
/// ``` pub async fn notified(&self) { Notified { notify: self, state: State::Init, waiter: UnsafeCell::new(Waiter { pointers: linked_list::Pointers::new(), waker: None, notified: false, _p: PhantomPinned, ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
c9f5bc29158a6f3a786e9d67df8da31524e8a9c3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c9f5bc29158a6f3a786e9d67df8da31524e8a9c3/tokio/src/sync/notify.rs
201
260
tokio-rs/tokio:tokio/src/sync/notify.rs:7
/// tokio::spawn(async move { /// notify2.notified().await; /// println!("received notification"); /// }); /// /// println!("sending notification"); /// notify.notify(); /// } /// ``` pub fn notify(&self) { // Load the current state let...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
c9f5bc29158a6f3a786e9d67df8da31524e8a9c3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c9f5bc29158a6f3a786e9d67df8da31524e8a9c3/tokio/src/sync/notify.rs
241
300
tokio-rs/tokio:tokio/src/sync/notify.rs:12
// Safety: called while locked let w = unsafe { &mut *waiter.get() }; if w.notified { // 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
c9f5bc29158a6f3a786e9d67df8da31524e8a9c3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c9f5bc29158a6f3a786e9d67df8da31524e8a9c3/tokio/src/sync/notify.rs
441
500
tokio-rs/tokio:tokio/src/sync/notify.rs:13
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
c9f5bc29158a6f3a786e9d67df8da31524e8a9c3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c9f5bc29158a6f3a786e9d67df8da31524e8a9c3/tokio/src/sync/notify.rs
481
540
tokio-rs/tokio:tokio/src/sync/notify.rs:3
/// /// pub async fn recv(&self) -> T { /// loop { /// // Drain values /// if let Some(value) = self.values.lock().unwrap().pop_front() { /// return value; /// } /// /// // Wait for values to be available /// self.notify.notified()....
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
0ccc09ac92c17ca81a2fd19fe7c7fe4c00e40c30
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0ccc09ac92c17ca81a2fd19fe7c7fe4c00e40c30/tokio/src/sync/notify.rs
81
140
tokio-rs/tokio:tokio/src/sync/notify.rs:4
/// Future returned from `notified()` #[derive(Debug)] struct Notified<'a> { /// The `Notify` being received on. notify: &'a Notify, /// The current state of the receiving process. state: State, /// Entry in the waiter `LinkedList`. waiter: UnsafeCell<Waiter>, } unsafe impl<'a> Send for Notif...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
0ccc09ac92c17ca81a2fd19fe7c7fe4c00e40c30
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0ccc09ac92c17ca81a2fd19fe7c7fe4c00e40c30/tokio/src/sync/notify.rs
121
180
tokio-rs/tokio:tokio/src/sync/notify.rs:5
/// /// let notify = Notify::new(); /// ``` pub fn new() -> Notify { Notify { state: AtomicU8::new(0), waiters: Mutex::new(LinkedList::new()), } } /// Wait for a notification. /// /// Each `Notify` value holds a single permit. If a permit is available...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
0ccc09ac92c17ca81a2fd19fe7c7fe4c00e40c30
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0ccc09ac92c17ca81a2fd19fe7c7fe4c00e40c30/tokio/src/sync/notify.rs
161
220
tokio-rs/tokio:tokio/src/sync/notify.rs:6
Notified { notify: self, state: State::Init, waiter: UnsafeCell::new(Waiter { pointers: linked_list::Pointers::new(), waker: None, notified: false, _p: PhantomPinned, }), } .await } /...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
0ccc09ac92c17ca81a2fd19fe7c7fe4c00e40c30
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0ccc09ac92c17ca81a2fd19fe7c7fe4c00e40c30/tokio/src/sync/notify.rs
201
260
tokio-rs/tokio:tokio/src/sync/notify.rs:7
/// println!("received notification"); /// }); /// /// println!("sending notification"); /// notify.notify(); /// } /// ``` pub fn notify(&self) { // Load the current state let mut curr = self.state.load(SeqCst); // If the state is `EMPTY`, transi...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
0ccc09ac92c17ca81a2fd19fe7c7fe4c00e40c30
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0ccc09ac92c17ca81a2fd19fe7c7fe4c00e40c30/tokio/src/sync/notify.rs
241
300
tokio-rs/tokio:tokio/src/sync/notify.rs:8
impl Default for Notify { fn default() -> Notify { Notify::new() } } fn notify_locked(waiters: &mut LinkedList<Waiter>, state: &AtomicU8, curr: u8) -> Option<Waker> { loop { match curr { EMPTY | NOTIFIED => { let res = state.compare_exchange(curr, NOTIFIED, SeqCs...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
0ccc09ac92c17ca81a2fd19fe7c7fe4c00e40c30
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0ccc09ac92c17ca81a2fd19fe7c7fe4c00e40c30/tokio/src/sync/notify.rs
281
340
tokio-rs/tokio:tokio/src/sync/notify.rs:9
// must be transitioned to `EMPTY`. As transitioning // **from** `WAITING` requires the lock to be held, a // `store` is sufficient. state.store(EMPTY, SeqCst); } return waker; } _ => unreachable!(), ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
0ccc09ac92c17ca81a2fd19fe7c7fe4c00e40c30
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0ccc09ac92c17ca81a2fd19fe7c7fe4c00e40c30/tokio/src/sync/notify.rs
321
380
tokio-rs/tokio:tokio/src/sync/notify.rs:10
match *state { Init => { // Optimistically try acquiring a pending notification let res = notify .state .compare_exchange(NOTIFIED, EMPTY, SeqCst, SeqCst); if res.is_ok() { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
0ccc09ac92c17ca81a2fd19fe7c7fe4c00e40c30
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0ccc09ac92c17ca81a2fd19fe7c7fe4c00e40c30/tokio/src/sync/notify.rs
361
420
tokio-rs/tokio:tokio/src/sync/notify.rs:11
.state .compare_exchange(NOTIFIED, EMPTY, SeqCst, SeqCst); match res { Ok(_) => { // Acquired the notification *state = Done; ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
0ccc09ac92c17ca81a2fd19fe7c7fe4c00e40c30
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0ccc09ac92c17ca81a2fd19fe7c7fe4c00e40c30/tokio/src/sync/notify.rs
401
460
tokio-rs/tokio:tokio/src/sync/notify.rs:12
let w = unsafe { &mut *waiter.get() }; if w.notified { // Our waker has been notified. Reset the fields and // remove it from the list. w.waker = None; w.notified = false; *state...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
0ccc09ac92c17ca81a2fd19fe7c7fe4c00e40c30
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0ccc09ac92c17ca81a2fd19fe7c7fe4c00e40c30/tokio/src/sync/notify.rs
441
500
tokio-rs/tokio:tokio/src/sync/notify.rs:13
// 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 mut notify_state = WAITING; let mut waiters = notify.waiters.lock().unwra...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
0ccc09ac92c17ca81a2fd19fe7c7fe4c00e40c30
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0ccc09ac92c17ca81a2fd19fe7c7fe4c00e40c30/tokio/src/sync/notify.rs
481
540
tokio-rs/tokio:tokio/src/sync/notify.rs:14
// // Safety: with the entry removed from the linked list, there can be // no concurrent access to the entry let notified = unsafe { (*waiter.get()).notified }; if notified { if let Some(waker) = notify_locked(&mut waiters, &notify.state, notify_state) { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
0ccc09ac92c17ca81a2fd19fe7c7fe4c00e40c30
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0ccc09ac92c17ca81a2fd19fe7c7fe4c00e40c30/tokio/src/sync/notify.rs
521
556
tokio-rs/tokio:tokio/src/sync/notify.rs:8
impl Default for Notify { fn default() -> Notify { Notify::new() } } fn notify_locked(waiters: &mut LinkedList<Waiter>, state: &AtomicU8, curr: u8) -> Option<Waker> { loop { match curr { EMPTY | NOTIFIED => { let res = state.compare_exchange(curr, NOTIFIED, SeqCs...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
06bcbe8dcf52a464d8e89866449397df1c794338
github
async-runtime
https://github.com/tokio-rs/tokio/blob/06bcbe8dcf52a464d8e89866449397df1c794338/tokio/src/sync/notify.rs
281
340
tokio-rs/tokio:tokio/src/sync/notify.rs:11
.state .compare_exchange(NOTIFIED, EMPTY, SeqCst, SeqCst); match res { Ok(_) => { // Acquired the notification *state = Done; ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
06bcbe8dcf52a464d8e89866449397df1c794338
github
async-runtime
https://github.com/tokio-rs/tokio/blob/06bcbe8dcf52a464d8e89866449397df1c794338/tokio/src/sync/notify.rs
401
460
tokio-rs/tokio:tokio/src/sync/notify.rs:12
if w.notified { // Our waker has been notified. Reset the fields and // remove it from the list. w.waker = None; w.notified = false; *state = Done; } else { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
06bcbe8dcf52a464d8e89866449397df1c794338
github
async-runtime
https://github.com/tokio-rs/tokio/blob/06bcbe8dcf52a464d8e89866449397df1c794338/tokio/src/sync/notify.rs
441
500
tokio-rs/tokio:tokio/src/sync/notify.rs:13
// longer stored in the linked list. if let Waiting = *state { let mut notify_state = WAITING; let mut waiters = notify.waiters.lock().unwrap(); // `Notify.state` may be in any of the three states (Empty, Waiting, // Notified). It doesn't actually matter what the...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
06bcbe8dcf52a464d8e89866449397df1c794338
github
async-runtime
https://github.com/tokio-rs/tokio/blob/06bcbe8dcf52a464d8e89866449397df1c794338/tokio/src/sync/notify.rs
481
540
tokio-rs/tokio:tokio/src/sync/notify.rs:14
// no concurrent access to the entry let notified = unsafe { (*waiter.get()).notified }; if 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
06bcbe8dcf52a464d8e89866449397df1c794338
github
async-runtime
https://github.com/tokio-rs/tokio/blob/06bcbe8dcf52a464d8e89866449397df1c794338/tokio/src/sync/notify.rs
521
555
tokio-rs/tokio:tokio/src/sync/notify.rs:3
/// // Drain values /// if let Some(value) = self.values.lock().unwrap().pop_front() { /// return value; /// } /// /// // Wait for values to be available /// self.notify.notified().await; /// } /// } /// } /// ``` /// /// [park]: st...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
8b7ea0ff5cad2522d3113b77e9b6d95b507dee3b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8b7ea0ff5cad2522d3113b77e9b6d95b507dee3b/tokio/src/sync/notify.rs
81
140
tokio-rs/tokio:tokio/src/sync/notify.rs:4
/// Entry in the waiter `LinkedList`. waiter: linked_list::Entry<Waiter>, } #[derive(Debug)] enum State { Init, Waiting, Done, } /// Initial "idle" state const EMPTY: u8 = 0; /// One or more threads are currently waiting to be notified. const WAITING: u8 = 1; /// Pending notification const NOTIFIED:...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
8b7ea0ff5cad2522d3113b77e9b6d95b507dee3b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8b7ea0ff5cad2522d3113b77e9b6d95b507dee3b/tokio/src/sync/notify.rs
121
180
tokio-rs/tokio:tokio/src/sync/notify.rs:6
/// /// 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()`. /// /// At most one permit may b...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
8b7ea0ff5cad2522d3113b77e9b6d95b507dee3b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8b7ea0ff5cad2522d3113b77e9b6d95b507dee3b/tokio/src/sync/notify.rs
201
260
tokio-rs/tokio:tokio/src/sync/notify.rs:7
// happens-before synchronization must happen between this atomic // operation and a task calling `notified().await`. let res = self.state.compare_exchange(curr, NOTIFIED, SeqCst, SeqCst); match res { // No waiters, no further work to do Ok(_) => retu...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
8b7ea0ff5cad2522d3113b77e9b6d95b507dee3b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8b7ea0ff5cad2522d3113b77e9b6d95b507dee3b/tokio/src/sync/notify.rs
241
300
tokio-rs/tokio:tokio/src/sync/notify.rs:8
Ok(_) => return None, Err(actual) => { assert!(actual == EMPTY || actual == NOTIFIED); state.store(NOTIFIED, SeqCst); return None; } } } WAITING => { //...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
8b7ea0ff5cad2522d3113b77e9b6d95b507dee3b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8b7ea0ff5cad2522d3113b77e9b6d95b507dee3b/tokio/src/sync/notify.rs
281
340
tokio-rs/tokio:tokio/src/sync/notify.rs:9
/// as a custom drop implementation is needed. fn project( self: Pin<&mut Self>, ) -> (&Notify, &mut State, Pin<&mut linked_list::Entry<Waiter>>) { unsafe { // Safety: both `notify` and `state` are `Unpin`. is_unpin::<&Notify>(); is_unpin::<AtomicU8>(); ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
8b7ea0ff5cad2522d3113b77e9b6d95b507dee3b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8b7ea0ff5cad2522d3113b77e9b6d95b507dee3b/tokio/src/sync/notify.rs
321
380
tokio-rs/tokio:tokio/src/sync/notify.rs:10
} // Acquire the lock and attempt to transition to the waiting // state. let mut waiters = notify.waiters.lock().unwrap(); // Reload the state with the lock held let mut curr = notify.state.load(SeqCst); ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
8b7ea0ff5cad2522d3113b77e9b6d95b507dee3b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8b7ea0ff5cad2522d3113b77e9b6d95b507dee3b/tokio/src/sync/notify.rs
361
420
tokio-rs/tokio:tokio/src/sync/notify.rs:11
curr = actual; } } } _ => unreachable!(), } } // Safety: called while locked. unsafe { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
8b7ea0ff5cad2522d3113b77e9b6d95b507dee3b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8b7ea0ff5cad2522d3113b77e9b6d95b507dee3b/tokio/src/sync/notify.rs
401
460
tokio-rs/tokio:tokio/src/sync/notify.rs:12
} 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 ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
8b7ea0ff5cad2522d3113b77e9b6d95b507dee3b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8b7ea0ff5cad2522d3113b77e9b6d95b507dee3b/tokio/src/sync/notify.rs
441
500
tokio-rs/tokio:tokio/src/sync/notify.rs:13
// seem like this routine does not handle the case where the // receiver is notified but has not yet observed the notification. // If this happens, no matter how many notifications happen between // this receiver being notified and the receive future dropping, all // we n...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/notify.rs
MIT
8b7ea0ff5cad2522d3113b77e9b6d95b507dee3b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8b7ea0ff5cad2522d3113b77e9b6d95b507dee3b/tokio/src/sync/notify.rs
481
523
tokio-rs/tokio:tokio/src/sync/once_cell.rs:2
/// /// static ONCE: OnceCell<u32> = OnceCell::const_new(); /// /// # #[tokio::main(flavor = "current_thread")] /// # async fn main() { /// let result = ONCE.get_or_init(some_computation).await; /// assert_eq!(*result, 2); /// # } /// ``` /// /// It is often useful to write a wrapper method for accessing the value. ///...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/once_cell.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/once_cell.rs
41
100
tokio-rs/tokio:tokio/src/sync/once_cell.rs:3
impl<T: fmt::Debug> fmt::Debug for OnceCell<T> { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { fmt.debug_struct("OnceCell") .field("value", &self.get()) .finish() } } impl<T: Clone> Clone for OnceCell<T> { fn clone(&self) -> OnceCell<T> { OnceCell::new...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/once_cell.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/once_cell.rs
81
140
tokio-rs/tokio:tokio/src/sync/once_cell.rs:4
} } } impl<T> OnceCell<T> { /// Creates a new empty `OnceCell` instance. pub fn new() -> Self { OnceCell { value_set: AtomicBool::new(false), value: UnsafeCell::new(MaybeUninit::uninit()), semaphore: Semaphore::new(1), } } /// Creates a new empty...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/once_cell.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/once_cell.rs
121
180
tokio-rs/tokio:tokio/src/sync/once_cell.rs:5
/// assert_eq!(*result, 2); /// # } /// ``` /// /// [`tokio-console`]: https://github.com/tokio-rs/console /// [unstable feature]: crate#unstable-features #[cfg(not(all(loom, test)))] pub const fn const_new() -> Self { OnceCell { value_set: AtomicBool::new(false), ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/once_cell.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/once_cell.rs
161
220
tokio-rs/tokio:tokio/src/sync/once_cell.rs:6
/// /// ``` /// use tokio::sync::OnceCell; /// /// static ONCE: OnceCell<u32> = OnceCell::const_new_with(1); /// /// async fn get_global_integer() -> &'static u32 { /// ONCE.get_or_init(|| async { /// 1 + 1 /// }).await /// } /// /// # #[tokio::main(flavor...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/once_cell.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/once_cell.rs
201
260
tokio-rs/tokio:tokio/src/sync/once_cell.rs:7
fn initialized_mut(&mut self) -> bool { *self.value_set.get_mut() } // SAFETY: The OnceCell must not be empty. unsafe fn get_unchecked(&self) -> &T { unsafe { &*self.value.with(|ptr| (*ptr).as_ptr()) } } // SAFETY: The OnceCell must not be empty. unsafe fn get_unchecked_mut(&mu...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/once_cell.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/once_cell.rs
241
300
tokio-rs/tokio:tokio/src/sync/once_cell.rs:8
None } } /// Returns a mutable reference to the value currently stored in the /// `OnceCell`, or `None` if the `OnceCell` is empty. /// /// Since this call borrows the `OnceCell` mutably, it is safe to mutate the /// value inside the `OnceCell` — the mutable borrow statically guarantees...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/once_cell.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/once_cell.rs
281
340
tokio-rs/tokio:tokio/src/sync/once_cell.rs:9
self.set_value(value, permit); Ok(()) } Err(TryAcquireError::NoPermits) => { // Some other task is holding the permit. That task is // currently trying to initialize the value. Err(SetError::InitializingError(value)) } ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/once_cell.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/once_cell.rs
321
380
tokio-rs/tokio:tokio/src/sync/once_cell.rs:10
// Here we try to acquire the semaphore permit. Holding the permit // will allow us to set the value of the OnceCell, and prevents // other tasks from initializing the OnceCell while we are holding // it. match self.semaphore.acquire().await { Ok(permit) =...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/once_cell.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/once_cell.rs
361
420
tokio-rs/tokio:tokio/src/sync/once_cell.rs:11
where F: FnOnce() -> Fut, Fut: Future<Output = Result<T, E>>, { crate::trace::async_trace_leaf().await; if self.initialized() { // SAFETY: The OnceCell has been fully initialized. unsafe { Ok(self.get_unchecked()) } } else { // Here we try...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/once_cell.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/once_cell.rs
401
460
tokio-rs/tokio:tokio/src/sync/once_cell.rs:12
/// Returns `None` if the cell is empty. pub fn into_inner(mut self) -> Option<T> { if self.initialized_mut() { // Set to uninitialized for the destructor of `OnceCell` to work properly *self.value_set.get_mut() = false; Some(unsafe { self.value.with(|ptr| ptr::read(ptr)....
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/once_cell.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/once_cell.rs
441
500
tokio-rs/tokio:tokio/src/sync/once_cell.rs:13
/// The cell is currently being initialized. InitializingError(T), } impl<T> fmt::Display for SetError<T> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { SetError::AlreadyInitializedError(_) => write!(f, "AlreadyInitializedError"), SetError::Initializin...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/once_cell.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/once_cell.rs
481
512
tokio-rs/tokio:tokio/src/sync/once_cell.rs:6
/// /// ``` /// use tokio::sync::OnceCell; /// /// static ONCE: OnceCell<u32> = OnceCell::const_new_with(1); /// /// async fn get_global_integer() -> &'static u32 { /// ONCE.get_or_init(|| async { /// 1 + 1 /// }).await /// } /// /// # #[tokio::main(flavor...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/once_cell.rs
MIT
8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d/tokio/src/sync/once_cell.rs
201
260
tokio-rs/tokio:tokio/src/sync/once_cell.rs:7
fn initialized_mut(&mut self) -> bool { *self.value_set.get_mut() } // SAFETY: The OnceCell must not be empty. unsafe fn get_unchecked(&self) -> &T { &*self.value.with(|ptr| (*ptr).as_ptr()) } // SAFETY: The OnceCell must not be empty. unsafe fn get_unchecked_mut(&mut self) -> ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/once_cell.rs
MIT
8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d/tokio/src/sync/once_cell.rs
241
300
tokio-rs/tokio:tokio/src/sync/once_cell.rs:8
/// Returns a mutable reference to the value currently stored in the /// `OnceCell`, or `None` if the `OnceCell` is empty. /// /// Since this call borrows the `OnceCell` mutably, it is safe to mutate the /// value inside the `OnceCell` — the mutable borrow statically guarantees /// no other referenc...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/once_cell.rs
MIT
8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d/tokio/src/sync/once_cell.rs
281
340
tokio-rs/tokio:tokio/src/sync/once_cell.rs:9
// Some other task is holding the permit. That task is // currently trying to initialize the value. Err(SetError::InitializingError(value)) } Err(TryAcquireError::Closed) => { // The semaphore was closed. Some other task has initialized ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/once_cell.rs
MIT
8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d/tokio/src/sync/once_cell.rs
321
380
tokio-rs/tokio:tokio/src/sync/once_cell.rs:10
match self.semaphore.acquire().await { Ok(permit) => { debug_assert!(!self.initialized()); // If `f()` panics or `select!` is called, this // `get_or_init` call is aborted and the semaphore permit is // dropped. ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/once_cell.rs
MIT
8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d/tokio/src/sync/once_cell.rs
361
420
tokio-rs/tokio:tokio/src/sync/once_cell.rs:11
crate::trace::async_trace_leaf().await; if self.initialized() { // SAFETY: The OnceCell has been fully initialized. unsafe { Ok(self.get_unchecked()) } } else { // Here we try to acquire the semaphore permit. Holding the permit // will allow us to set the...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/once_cell.rs
MIT
8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d/tokio/src/sync/once_cell.rs
401
460