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/semaphore_ll.rs:16
PermitState::Waiting => { let ret = self.waiter.as_ref().unwrap().cancel_interest(); self.state = PermitState::Idle; ret } PermitState::Acquired => { self.state = PermitState::Idle; true } } }...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/sync/semaphore_ll.rs
MIT
9211adbe01661585cd1831214279262024d04816
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9211adbe01661585cd1831214279262024d04816/tokio/src/sync/semaphore_ll.rs
601
660
tokio-rs/tokio:tokio/src/sync/semaphore_ll.rs:17
impl TryAcquireError { fn closed() -> TryAcquireError { TryAcquireError { kind: ErrorKind::Closed, } } fn no_permits() -> TryAcquireError { TryAcquireError { kind: ErrorKind::NoPermits, } } /// Returns true if the error was caused by a closed...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/sync/semaphore_ll.rs
MIT
9211adbe01661585cd1831214279262024d04816
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9211adbe01661585cd1831214279262024d04816/tokio/src/sync/semaphore_ll.rs
641
700
tokio-rs/tokio:tokio/src/sync/semaphore_ll.rs:18
} impl ::std::error::Error for TryAcquireError {} // ===== impl WaiterNode ===== impl WaiterNode { fn new() -> WaiterNode { WaiterNode { state: AtomicUsize::new(NodeState::new().to_usize()), waker: AtomicWaker::new(), next: AtomicPtr::new(ptr::null_mut()), } ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/sync/semaphore_ll.rs
MIT
9211adbe01661585cd1831214279262024d04816
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9211adbe01661585cd1831214279262024d04816/tokio/src/sync/semaphore_ll.rs
681
740
tokio-rs/tokio:tokio/src/sync/semaphore_ll.rs:19
fn cancel_interest(&self) -> bool { use self::NodeState::*; match Queued.compare_exchange(&self.state, QueuedWaiting, AcqRel, Acquire) { // Successfully removed interest from the queued node. The permit // has not been assigned to the node. Ok(_) => false, ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/sync/semaphore_ll.rs
MIT
9211adbe01661585cd1831214279262024d04816
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9211adbe01661585cd1831214279262024d04816/tokio/src/sync/semaphore_ll.rs
721
780
tokio-rs/tokio:tokio/src/sync/semaphore_ll.rs:20
Ok(_) => { if curr.is_queued() { return false; } else { // Transitioned to queued, reset next pointer self.next.store(ptr::null_mut(), Relaxed); return true; } ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/sync/semaphore_ll.rs
MIT
9211adbe01661585cd1831214279262024d04816
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9211adbe01661585cd1831214279262024d04816/tokio/src/sync/semaphore_ll.rs
761
820
tokio-rs/tokio:tokio/src/sync/semaphore_ll.rs:21
QueuedWaiting => { self.waker.wake(); return true; } _ => return false, }, Err(actual) => curr = actual, } } } fn revert_to_idle(&self) { use self::NodeState::Idle...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/sync/semaphore_ll.rs
MIT
9211adbe01661585cd1831214279262024d04816
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9211adbe01661585cd1831214279262024d04816/tokio/src/sync/semaphore_ll.rs
801
860
tokio-rs/tokio:tokio/src/sync/semaphore_ll.rs:22
const NUM_SHIFT: usize = 2; impl SemState { /// Returns a new default `State` value. fn new(permits: usize, stub: &WaiterNode) -> SemState { assert!(permits <= MAX_PERMITS); if permits > 0 { SemState((permits << NUM_SHIFT) | NUM_FLAG) } else { SemState(stub as *...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/sync/semaphore_ll.rs
MIT
9211adbe01661585cd1831214279262024d04816
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9211adbe01661585cd1831214279262024d04816/tokio/src/sync/semaphore_ll.rs
841
900
tokio-rs/tokio:tokio/src/sync/semaphore_ll.rs:23
!self.has_available_permits() && !self.is_stub(stub) } /// Try to acquire a permit /// /// # Return /// /// Returns `true` if the permit was acquired, `false` otherwise. If `false` /// is returned, it can be assumed that `State` represents the head pointer /// in the mpsc channel. f...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/sync/semaphore_ll.rs
MIT
9211adbe01661585cd1831214279262024d04816
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9211adbe01661585cd1831214279262024d04816/tokio/src/sync/semaphore_ll.rs
881
940
tokio-rs/tokio:tokio/src/sync/semaphore_ll.rs:24
self.0 += permits << NUM_SHIFT; } fn is_waiter(self) -> bool { self.0 & NUM_FLAG == 0 } /// Returns the waiter, if one is set. fn waiter(self) -> Option<NonNull<WaiterNode>> { if self.is_waiter() { let waiter = NonNull::new(self.as_ptr()).expect("null pointer stored"); ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/sync/semaphore_ll.rs
MIT
9211adbe01661585cd1831214279262024d04816
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9211adbe01661585cd1831214279262024d04816/tokio/src/sync/semaphore_ll.rs
921
980
tokio-rs/tokio:tokio/src/sync/semaphore_ll.rs:25
let value = cell.load(ordering); SemState(value) } /// Swap the values fn swap(self, cell: &AtomicUsize, ordering: Ordering) -> SemState { let prev = SemState(cell.swap(self.to_usize(), ordering)); debug_assert_eq!(prev.is_closed(), self.is_closed()); prev } /// Com...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/sync/semaphore_ll.rs
MIT
9211adbe01661585cd1831214279262024d04816
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9211adbe01661585cd1831214279262024d04816/tokio/src/sync/semaphore_ll.rs
961
1,020
tokio-rs/tokio:tokio/src/sync/semaphore_ll.rs:26
impl fmt::Debug for SemState { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { let mut fmt = fmt.debug_struct("SemState"); if self.is_waiter() { fmt.field("state", &"<waiter>"); } else { fmt.field("permits", &self.available_permits()); } ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/sync/semaphore_ll.rs
MIT
9211adbe01661585cd1831214279262024d04816
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9211adbe01661585cd1831214279262024d04816/tokio/src/sync/semaphore_ll.rs
1,001
1,060
tokio-rs/tokio:tokio/src/sync/semaphore_ll.rs:27
fn store(cell: &AtomicUsize, value: NodeState, ordering: Ordering) { cell.store(value.to_usize(), ordering); } fn compare_exchange( self, cell: &AtomicUsize, prev: NodeState, success: Ordering, failure: Ordering, ) -> Result<NodeState, NodeState> { ce...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/sync/semaphore_ll.rs
MIT
9211adbe01661585cd1831214279262024d04816
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9211adbe01661585cd1831214279262024d04816/tokio/src/sync/semaphore_ll.rs
1,041
1,070
tokio-rs/tokio:tokio/src/sync/set_once.rs:3
/// // subsequent set calls will fail /// assert!(arc.set(30).is_err()); /// /// println!("{:?}", arc.get()); /// /// Ok(()) /// # } /// ``` /// /// [`asyncio.Event`]: https://docs.python.org/3/library/asyncio-sync.html#asyncio.Event pub struct SetOnce<T> { value_set: AtomicBool, value: UnsafeCell<MaybeUninit<T...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/set_once.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/set_once.rs
81
140
tokio-rs/tokio:tokio/src/sync/set_once.rs:4
} impl<T: Eq> Eq for SetOnce<T> {} impl<T> Drop for SetOnce<T> { fn drop(&mut self) { // TODO: Use get_mut() if self.value_set.load(Ordering::Relaxed) { // SAFETY: If the value_set is true, then the value is initialized // then there is a value to be dropped and this is saf...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/set_once.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/set_once.rs
121
180
tokio-rs/tokio:tokio/src/sync/set_once.rs:5
/// When using the `tracing` [unstable feature], a `SetOnce` created with /// `const_new` will not be instrumented. As such, it will not be visible /// in [`tokio-console`]. Instead, [`SetOnce::new`] should be used to /// create an instrumented object if that is needed. /// /// # Example /// ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/set_once.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/set_once.rs
161
220
tokio-rs/tokio:tokio/src/sync/set_once.rs:6
/// /// [`SetOnce::new`]: crate::sync::SetOnce::new pub fn new_with(value: Option<T>) -> Self { if let Some(v) = value { SetOnce::from(v) } else { SetOnce::new() } } /// Creates a new `SetOnce` that contains the provided value. /// /// # Example ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/set_once.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/set_once.rs
201
260
tokio-rs/tokio:tokio/src/sync/set_once.rs:7
Self { value_set: AtomicBool::new(true), value: UnsafeCell::new(MaybeUninit::new(value)), notify: Notify::const_new(), } } /// Returns `true` if the `SetOnce` currently contains a value, and `false` /// otherwise. pub fn initialized(&self) -> bool { /...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/set_once.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/set_once.rs
241
300
tokio-rs/tokio:tokio/src/sync/set_once.rs:8
if self.initialized() { return Err(SetOnceError(value)); } // SAFETY: lock notify to ensure only one caller of set // can run at a time. let guard = self.notify.lock_waiter_list(); if self.initialized() { return Err(SetOnceError(value)); } ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/set_once.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/set_once.rs
281
340
tokio-rs/tokio:tokio/src/sync/set_once.rs:9
// SAFETY: The SetOnce is currently initialized, we can assume the // value is initialized and return that, when we return the value // we give the drop handler to the return scope. Some(unsafe { self.value.with_mut(|ptr| ptr::read(ptr).assume_init()) }) } else { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/set_once.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/set_once.rs
321
380
tokio-rs/tokio:tokio/src/sync/set_once.rs:10
// Since `get` gives us access to immutable references of the SetOnce, SetOnce // can only be Sync if T is Sync, otherwise SetOnce would allow sharing // references of !Sync values across threads. We need T to be Send in order for // SetOnce to by Sync because we can use `set` on `&SetOnce<T>` to send values // (of typ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/set_once.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/set_once.rs
361
388
tokio-rs/tokio:tokio/src/sync/set_once.rs:6
/// /// [`SetOnce::new`]: crate::sync::SetOnce::new pub fn new_with(value: Option<T>) -> Self { if let Some(v) = value { SetOnce::from(v) } else { SetOnce::new() } } /// Creates a new `SetOnce` that contains the provided value. /// /// # Example ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/set_once.rs
MIT
8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d/tokio/src/sync/set_once.rs
201
260
tokio-rs/tokio:tokio/src/sync/set_once.rs:7
Self { value_set: AtomicBool::new(true), value: UnsafeCell::new(MaybeUninit::new(value)), notify: Notify::const_new(), } } /// Returns `true` if the `SetOnce` currently contains a value, and `false` /// otherwise. pub fn initialized(&self) -> bool { /...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/set_once.rs
MIT
8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d/tokio/src/sync/set_once.rs
241
300
tokio-rs/tokio:tokio/src/sync/set_once.rs:3
/// // subsequent set calls will fail /// assert!(arc.set(30).is_err()); /// /// println!("{:?}", arc.get()); /// /// Ok(()) /// } /// ``` /// /// [`asyncio.Event`]: https://docs.python.org/3/library/asyncio-sync.html#asyncio.Event pub struct SetOnce<T> { value_set: AtomicBool, value: UnsafeCell...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/set_once.rs
MIT
37ca2f049c552fde50a2535de6dfc61ee6e96eed
github
async-runtime
https://github.com/tokio-rs/tokio/blob/37ca2f049c552fde50a2535de6dfc61ee6e96eed/tokio/src/sync/set_once.rs
81
140
tokio-rs/tokio:tokio/src/sync/set_once.rs:4
} impl<T: Eq> Eq for SetOnce<T> {} impl<T> Drop for SetOnce<T> { fn drop(&mut self) { // TODO: Use get_mut() if self.value_set.load(Ordering::Relaxed) { // SAFETY: If the value_set is true, then the value is initialized // then there is a value to be dropped and this is saf...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/set_once.rs
MIT
37ca2f049c552fde50a2535de6dfc61ee6e96eed
github
async-runtime
https://github.com/tokio-rs/tokio/blob/37ca2f049c552fde50a2535de6dfc61ee6e96eed/tokio/src/sync/set_once.rs
121
180
tokio-rs/tokio:tokio/src/sync/set_once.rs:5
/// When using the `tracing` [unstable feature], a `SetOnce` created with /// `const_new` will not be instrumented. As such, it will not be visible /// in [`tokio-console`]. Instead, [`SetOnce::new`] should be used to /// create an instrumented object if that is needed. /// /// # Example /// ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/set_once.rs
MIT
37ca2f049c552fde50a2535de6dfc61ee6e96eed
github
async-runtime
https://github.com/tokio-rs/tokio/blob/37ca2f049c552fde50a2535de6dfc61ee6e96eed/tokio/src/sync/set_once.rs
161
220
tokio-rs/tokio:tokio/src/sync/set_once.rs:6
/// /// [`SetOnce::new`]: crate::sync::SetOnce::new pub fn new_with(value: Option<T>) -> Self { if let Some(v) = value { SetOnce::from(v) } else { SetOnce::new() } } /// Creates a new `SetOnce` that contains the provided value. /// /// # Example ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/set_once.rs
MIT
37ca2f049c552fde50a2535de6dfc61ee6e96eed
github
async-runtime
https://github.com/tokio-rs/tokio/blob/37ca2f049c552fde50a2535de6dfc61ee6e96eed/tokio/src/sync/set_once.rs
201
260
tokio-rs/tokio:tokio/src/sync/set_once.rs:3
/// /// println!("{:?}", arc.get()); /// /// Ok(()) /// } /// ``` /// /// [`asyncio.Event`]: https://docs.python.org/3/library/asyncio-sync.html#asyncio.Event pub struct SetOnce<T> { value_set: AtomicBool, value: UnsafeCell<MaybeUninit<T>>, notify: Notify, // we lock the mutex inside set to ensu...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/set_once.rs
MIT
9741c90f9f8b14a7d78d7629a29a281602d5f2b9
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9741c90f9f8b14a7d78d7629a29a281602d5f2b9/tokio/src/sync/set_once.rs
81
140
tokio-rs/tokio:tokio/src/sync/set_once.rs:4
} } impl<T: Eq> Eq for SetOnce<T> {} impl<T> Drop for SetOnce<T> { fn drop(&mut self) { // TODO: Use get_mut() if self.value_set.load(Ordering::Relaxed) { // SAFETY: If the value_set is true, then the value is initialized // then there is a value to be dropped and this is s...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/set_once.rs
MIT
9741c90f9f8b14a7d78d7629a29a281602d5f2b9
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9741c90f9f8b14a7d78d7629a29a281602d5f2b9/tokio/src/sync/set_once.rs
121
180
tokio-rs/tokio:tokio/src/sync/set_once.rs:5
/// Equivalent to `SetOnce::new`, except that it can be used in static /// variables. /// /// When using the `tracing` [unstable feature], a `SetOnce` created with /// `const_new` will not be instrumented. As such, it will not be visible /// in [`tokio-console`]. Instead, [`SetOnce::new`] should be ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/set_once.rs
MIT
9741c90f9f8b14a7d78d7629a29a281602d5f2b9
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9741c90f9f8b14a7d78d7629a29a281602d5f2b9/tokio/src/sync/set_once.rs
161
220
tokio-rs/tokio:tokio/src/sync/set_once.rs:6
/// Creates a new `SetOnce` that contains the provided value, if any. /// /// If the `Option` is `None`, this is equivalent to `SetOnce::new`. /// /// [`SetOnce::new`]: crate::sync::SetOnce::new pub fn new_with(value: Option<T>) -> Self { if let Some(v) = value { SetOnce::from(v)...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/set_once.rs
MIT
9741c90f9f8b14a7d78d7629a29a281602d5f2b9
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9741c90f9f8b14a7d78d7629a29a281602d5f2b9/tokio/src/sync/set_once.rs
201
260
tokio-rs/tokio:tokio/src/sync/set_once.rs:7
/// [`tokio-console`]: https://github.com/tokio-rs/console /// [unstable feature]: crate#unstable-features #[cfg(not(all(loom, test)))] pub const fn const_new_with(value: T) -> Self { Self { value_set: AtomicBool::new(true), value: UnsafeCell::new(MaybeUninit::new(value)), ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/set_once.rs
MIT
9741c90f9f8b14a7d78d7629a29a281602d5f2b9
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9741c90f9f8b14a7d78d7629a29a281602d5f2b9/tokio/src/sync/set_once.rs
241
300
tokio-rs/tokio:tokio/src/sync/set_once.rs:8
/// If the `SetOnce` already has a value, this call will fail with an /// [`SetOnceError`]. /// /// [`SetOnceError`]: crate::sync::SetOnceError pub fn set(&self, value: T) -> Result<(), SetOnceError<T>> { if self.initialized() { return Err(SetOnceError(value)); } // ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/set_once.rs
MIT
9741c90f9f8b14a7d78d7629a29a281602d5f2b9
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9741c90f9f8b14a7d78d7629a29a281602d5f2b9/tokio/src/sync/set_once.rs
281
340
tokio-rs/tokio:tokio/src/sync/set_once.rs:9
pub fn into_inner(self) -> Option<T> { // TODO: Use get_mut() let value_set = self.value_set.load(Ordering::Relaxed); if value_set { // Since we have taken ownership of self, its drop implementation // will be called by the end of this function, to prevent a double ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/set_once.rs
MIT
9741c90f9f8b14a7d78d7629a29a281602d5f2b9
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9741c90f9f8b14a7d78d7629a29a281602d5f2b9/tokio/src/sync/set_once.rs
321
380
tokio-rs/tokio:tokio/src/sync/set_once.rs:10
if self.value_set.load(Ordering::Relaxed) { // SAFETY: the state is initialized return unsafe { self.get_unchecked() }; } } // wait until the value is set notify_fut.await; } } } // Since `get` gives us access to i...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/set_once.rs
MIT
9741c90f9f8b14a7d78d7629a29a281602d5f2b9
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9741c90f9f8b14a7d78d7629a29a281602d5f2b9/tokio/src/sync/set_once.rs
361
401
tokio-rs/tokio:tokio/src/sync/set_once.rs:9
pub fn into_inner(self) -> Option<T> { // TODO: Use get_mut() let value_set = self.value_set.load(Ordering::Relaxed); if value_set { // Since we have taken ownership of self, its drop implementation // will be called by the end of this function, to prevent a double ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/set_once.rs
MIT
ce41896f8dcbc6249df3279600f45f7a65915cf6
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ce41896f8dcbc6249df3279600f45f7a65915cf6/tokio/src/sync/set_once.rs
321
380
tokio-rs/tokio:tokio/src/sync/set_once.rs:10
// will see the creation of `notify_fut` in case the check // fails. let _guard = self.lock.lock(); if self.value_set.load(Ordering::Relaxed) { // SAFETY: the state is initialized return unsafe { self.get_unchecked() }; ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/set_once.rs
MIT
ce41896f8dcbc6249df3279600f45f7a65915cf6
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ce41896f8dcbc6249df3279600f45f7a65915cf6/tokio/src/sync/set_once.rs
361
404
tokio-rs/tokio:tokio/src/sync/set_once.rs:3
/// /// println!("{:?}", arc.get()); /// /// Ok(()) /// } /// ``` /// /// [`asyncio.Event`]: https://docs.python.org/3/library/asyncio-event.html pub struct SetOnce<T> { value_set: AtomicBool, value: UnsafeCell<MaybeUninit<T>>, notify: Notify, // we lock the mutex inside set to ensure // onl...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/set_once.rs
MIT
911ab21d7012a50e53971ad1292a9f18de22d4c8
github
async-runtime
https://github.com/tokio-rs/tokio/blob/911ab21d7012a50e53971ad1292a9f18de22d4c8/tokio/src/sync/set_once.rs
81
140
tokio-rs/tokio:tokio/src/sync/task/atomic_waker.rs:1
#![cfg_attr(any(loom, not(feature = "sync")), allow(dead_code, unreachable_pub))] use crate::loom::cell::UnsafeCell; use crate::loom::hint; use crate::loom::sync::atomic::AtomicUsize; use std::fmt; use std::panic::{resume_unwind, AssertUnwindSafe, RefUnwindSafe, UnwindSafe}; use std::sync::atomic::Ordering::{AcqRel, ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/task/atomic_waker.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/task/atomic_waker.rs
1
60
tokio-rs/tokio:tokio/src/sync/task/atomic_waker.rs:4
// // Because of this, the task will do one of two things. // // 1) Observe the application state change that Thread B is waking on. In // this case, it is OK for Thread B's wake to be lost. // // 2) Call register before attempting to observe the application state. Since // Thread A still holds the `wake` lock, t...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/task/atomic_waker.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/task/atomic_waker.rs
121
180
tokio-rs/tokio:tokio/src/sync/task/atomic_waker.rs:5
/// wake the `register` caller's task. /// /// It is safe to call `register` with multiple other threads concurrently /// calling `wake`. This will result in the `register` caller's current /// task being woken once. /// /// This function is safe to call concurrently, but this is generally a bad...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/task/atomic_waker.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/task/atomic_waker.rs
161
220
tokio-rs/tokio:tokio/src/sync/task/atomic_waker.rs:6
match new_waker_or_panic { Ok(new_waker) => { old_waker = self.waker.with_mut(|t| (*t).take()); self.waker.with_mut(|t| *t = Some(new_waker)); } Err(panic) => maybe_panic = Some(panic), ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/task/atomic_waker.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/task/atomic_waker.rs
201
260
tokio-rs/tokio:tokio/src/sync/task/atomic_waker.rs:7
self.state.swap(WAITING, AcqRel); // If `into_waker` panicked, then the waker in the // waker slot is actually the old waker. if maybe_panic.is_some() { old_waker = waker.take(); ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/task/atomic_waker.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/task/atomic_waker.rs
241
300
tokio-rs/tokio:tokio/src/sync/task/atomic_waker.rs:8
// state of the waker. waker.wake(); // This is equivalent to a spin lock, so use a spin hint. hint::spin_loop(); } state => { // In this case, a concurrent thread is holding the // "registering" lock. This probably...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/task/atomic_waker.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/task/atomic_waker.rs
281
340
tokio-rs/tokio:tokio/src/sync/task/atomic_waker.rs:9
// Release the lock. let old_state = self.state.swap(WAITING, Release); debug_assert!(old_state == WAKING); waker } state => { // There is a concurrent thread currently updating the // associated waker. ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/task/atomic_waker.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/task/atomic_waker.rs
321
380
tokio-rs/tokio:tokio/src/sync/task/atomic_waker.rs:10
fn wake(self); fn into_waker(self) -> Waker; } impl WakerRef for Waker { fn wake(self) { self.wake(); } fn into_waker(self) -> Waker { self } } impl WakerRef for &Waker { fn wake(self) { self.wake_by_ref(); } fn into_waker(self) -> Waker { self.clone()...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/task/atomic_waker.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/task/atomic_waker.rs
361
383
tokio-rs/tokio:tokio/src/sync/task/atomic_waker.rs:8
// state of the waker. waker.wake(); // This is equivalent to a spin lock, so use a spin hint. hint::spin_loop(); } state => { // In this case, a concurrent thread is holding the // "registering" lock. This probably...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/task/atomic_waker.rs
MIT
6871084629ad95c37c7136d865890ab2e371ea12
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/sync/task/atomic_waker.rs
281
340
tokio-rs/tokio:tokio/src/sync/task/atomic_waker.rs:9
// Release the lock self.state.fetch_and(!WAKING, Release); waker } state => { // There is a concurrent thread currently updating the // associated waker. // // Nothing more to do as the `WAKING` bit...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/task/atomic_waker.rs
MIT
6871084629ad95c37c7136d865890ab2e371ea12
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/sync/task/atomic_waker.rs
321
380
tokio-rs/tokio:tokio/src/sync/task/atomic_waker.rs:10
fn into_waker(self) -> Waker; } impl WakerRef for Waker { fn wake(self) { self.wake(); } fn into_waker(self) -> Waker { self } } impl WakerRef for &Waker { fn wake(self) { self.wake_by_ref(); } fn into_waker(self) -> Waker { self.clone() } }
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/task/atomic_waker.rs
MIT
6871084629ad95c37c7136d865890ab2e371ea12
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/sync/task/atomic_waker.rs
361
382
tokio-rs/tokio:tokio/src/sync/task/atomic_waker.rs:9
// Release the lock self.state.fetch_and(!WAKING, Release); waker } state => { // There is a concurrent thread currently updating the // associated waker. // // Nothing more to do as the `WAKING` bit...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/task/atomic_waker.rs
MIT
02141db1e1f8187ffcd5340046fc06f142274001
github
async-runtime
https://github.com/tokio-rs/tokio/blob/02141db1e1f8187ffcd5340046fc06f142274001/tokio/src/sync/task/atomic_waker.rs
321
380
tokio-rs/tokio:tokio/src/sync/task/atomic_waker.rs:10
fn into_waker(self) -> Waker; } impl WakerRef for Waker { fn wake(self) { self.wake() } fn into_waker(self) -> Waker { self } } impl WakerRef for &Waker { fn wake(self) { self.wake_by_ref() } fn into_waker(self) -> Waker { self.clone() } }
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/task/atomic_waker.rs
MIT
02141db1e1f8187ffcd5340046fc06f142274001
github
async-runtime
https://github.com/tokio-rs/tokio/blob/02141db1e1f8187ffcd5340046fc06f142274001/tokio/src/sync/task/atomic_waker.rs
361
382
tokio-rs/tokio:tokio/src/sync/task/atomic_waker.rs:1
#![cfg_attr(any(loom, not(feature = "sync")), allow(dead_code, unreachable_pub))] use crate::loom::cell::UnsafeCell; use crate::loom::sync::atomic::{self, AtomicUsize}; use std::fmt; use std::panic::{resume_unwind, AssertUnwindSafe, RefUnwindSafe, UnwindSafe}; use std::sync::atomic::Ordering::{AcqRel, Acquire, Releas...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/task/atomic_waker.rs
MIT
09b770c5db31a1f35631600e1d239679354da2dd
github
async-runtime
https://github.com/tokio-rs/tokio/blob/09b770c5db31a1f35631600e1d239679354da2dd/tokio/src/sync/task/atomic_waker.rs
1
60
tokio-rs/tokio:tokio/src/sync/task/atomic_waker.rs:4
// Because of this, the task will do one of two things. // // 1) Observe the application state change that Thread B is waking on. In // this case, it is OK for Thread B's wake to be lost. // // 2) Call register before attempting to observe the application state. Since // Thread A still holds the `wake` lock, the ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/task/atomic_waker.rs
MIT
09b770c5db31a1f35631600e1d239679354da2dd
github
async-runtime
https://github.com/tokio-rs/tokio/blob/09b770c5db31a1f35631600e1d239679354da2dd/tokio/src/sync/task/atomic_waker.rs
121
180
tokio-rs/tokio:tokio/src/sync/task/atomic_waker.rs:5
/// /// It is safe to call `register` with multiple other threads concurrently /// calling `wake`. This will result in the `register` caller's current /// task being woken once. /// /// This function is safe to call concurrently, but this is generally a bad /// idea. Concurrent calls to `registe...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/task/atomic_waker.rs
MIT
09b770c5db31a1f35631600e1d239679354da2dd
github
async-runtime
https://github.com/tokio-rs/tokio/blob/09b770c5db31a1f35631600e1d239679354da2dd/tokio/src/sync/task/atomic_waker.rs
161
220
tokio-rs/tokio:tokio/src/sync/task/atomic_waker.rs:6
Ok(new_waker) => { old_waker = self.waker.with_mut(|t| (*t).take()); self.waker.with_mut(|t| *t = Some(new_waker)); } Err(panic) => maybe_panic = Some(panic), } // Release the...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/task/atomic_waker.rs
MIT
09b770c5db31a1f35631600e1d239679354da2dd
github
async-runtime
https://github.com/tokio-rs/tokio/blob/09b770c5db31a1f35631600e1d239679354da2dd/tokio/src/sync/task/atomic_waker.rs
201
260
tokio-rs/tokio:tokio/src/sync/task/atomic_waker.rs:7
// If `into_waker` panicked, then the waker in the // waker slot is actually the old waker. if maybe_panic.is_some() { old_waker = waker.take(); } // We don't want to give the...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/task/atomic_waker.rs
MIT
09b770c5db31a1f35631600e1d239679354da2dd
github
async-runtime
https://github.com/tokio-rs/tokio/blob/09b770c5db31a1f35631600e1d239679354da2dd/tokio/src/sync/task/atomic_waker.rs
241
300
tokio-rs/tokio:tokio/src/sync/task/atomic_waker.rs:8
waker.wake(); // This is equivalent to a spin lock, so use a spin hint. // TODO: once we bump MSRV to 1.49+, use `hint::spin_loop` instead. #[allow(deprecated)] atomic::spin_loop_hint(); } state => { // In this case...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/task/atomic_waker.rs
MIT
09b770c5db31a1f35631600e1d239679354da2dd
github
async-runtime
https://github.com/tokio-rs/tokio/blob/09b770c5db31a1f35631600e1d239679354da2dd/tokio/src/sync/task/atomic_waker.rs
281
340
tokio-rs/tokio:tokio/src/sync/task/atomic_waker.rs:9
let waker = unsafe { self.waker.with_mut(|t| (*t).take()) }; // Release the lock self.state.fetch_and(!WAKING, Release); waker } state => { // There is a concurrent thread currently updating the // associated waker...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/task/atomic_waker.rs
MIT
09b770c5db31a1f35631600e1d239679354da2dd
github
async-runtime
https://github.com/tokio-rs/tokio/blob/09b770c5db31a1f35631600e1d239679354da2dd/tokio/src/sync/task/atomic_waker.rs
321
380
tokio-rs/tokio:tokio/src/sync/task/atomic_waker.rs:10
fn wake(self); fn into_waker(self) -> Waker; } impl WakerRef for Waker { fn wake(self) { self.wake() } fn into_waker(self) -> Waker { self } } impl WakerRef for &Waker { fn wake(self) { self.wake_by_ref() } fn into_waker(self) -> Waker { self.clone() ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/task/atomic_waker.rs
MIT
09b770c5db31a1f35631600e1d239679354da2dd
github
async-runtime
https://github.com/tokio-rs/tokio/blob/09b770c5db31a1f35631600e1d239679354da2dd/tokio/src/sync/task/atomic_waker.rs
361
383
tokio-rs/tokio:tokio/src/sync/task/atomic_waker.rs:4
// // 2) Call register before attempting to observe the application state. Since // Thread A still holds the `wake` lock, the call to `register` will result // in the task waking itself and get scheduled again. /// Idle state. const WAITING: usize = 0; /// A new waker value is being registered with the `AtomicW...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/task/atomic_waker.rs
MIT
03969cdae7674681d1b10926e6a56fbb8908dbb8
github
async-runtime
https://github.com/tokio-rs/tokio/blob/03969cdae7674681d1b10926e6a56fbb8908dbb8/tokio/src/sync/task/atomic_waker.rs
121
180
tokio-rs/tokio:tokio/src/sync/task/atomic_waker.rs:5
/// /// This function is safe to call concurrently, but this is generally a bad /// idea. Concurrent calls to `register` will attempt to register different /// tasks to be woken. One of the callers will win and have its task set, /// but there is no guarantee as to which caller will succeed. pub(cra...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/task/atomic_waker.rs
MIT
03969cdae7674681d1b10926e6a56fbb8908dbb8
github
async-runtime
https://github.com/tokio-rs/tokio/blob/03969cdae7674681d1b10926e6a56fbb8908dbb8/tokio/src/sync/task/atomic_waker.rs
161
220
tokio-rs/tokio:tokio/src/sync/task/atomic_waker.rs:6
// `WAKING`. debug_assert_eq!(actual, REGISTERING | WAKING); // Take the waker to wake once the atomic operation has // completed. let waker = self.waker.with_mut(|t| (*t).take()).unwrap(); ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/task/atomic_waker.rs
MIT
03969cdae7674681d1b10926e6a56fbb8908dbb8
github
async-runtime
https://github.com/tokio-rs/tokio/blob/03969cdae7674681d1b10926e6a56fbb8908dbb8/tokio/src/sync/task/atomic_waker.rs
201
260
tokio-rs/tokio:tokio/src/sync/task/atomic_waker.rs:7
} /// Wakes the task that last called `register`. /// /// If `register` has not been called yet, then this does nothing. pub(crate) fn wake(&self) { if let Some(waker) = self.take_waker() { waker.wake(); } } /// Attempts to take the `Waker` value out of the `AtomicW...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/task/atomic_waker.rs
MIT
03969cdae7674681d1b10926e6a56fbb8908dbb8
github
async-runtime
https://github.com/tokio-rs/tokio/blob/03969cdae7674681d1b10926e6a56fbb8908dbb8/tokio/src/sync/task/atomic_waker.rs
241
300
tokio-rs/tokio:tokio/src/sync/task/atomic_waker.rs:8
} } } impl Default for AtomicWaker { fn default() -> Self { AtomicWaker::new() } } impl fmt::Debug for AtomicWaker { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { write!(fmt, "AtomicWaker") } } unsafe impl Send for AtomicWaker {} unsafe impl Sync for AtomicWaker {} ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/task/atomic_waker.rs
MIT
03969cdae7674681d1b10926e6a56fbb8908dbb8
github
async-runtime
https://github.com/tokio-rs/tokio/blob/03969cdae7674681d1b10926e6a56fbb8908dbb8/tokio/src/sync/task/atomic_waker.rs
281
323
tokio-rs/tokio:tokio/src/sync/task/atomic_waker.rs:4
// // 2) Call register before attempting to observe the application state. Since // Thread A still holds the `wake` lock, the call to `register` will result // in the task waking itself and get scheduled again. /// Idle state const WAITING: usize = 0; /// A new waker value is being registered with the `AtomicWa...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/task/atomic_waker.rs
MIT
44a070d1b4531a60ed0af2b49dd99e66f912be1e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/44a070d1b4531a60ed0af2b49dd99e66f912be1e/tokio/src/sync/task/atomic_waker.rs
121
180
tokio-rs/tokio:tokio/src/sync/task/atomic_waker.rs:6
// `WAKING`. debug_assert_eq!(actual, REGISTERING | WAKING); // Take the waker to wake once the atomic operation has // completed. let waker = self.waker.with_mut(|t| (*t).take()).unwrap(); ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/task/atomic_waker.rs
MIT
770044caa70465fbe5d2851a8d9a0bc0e5e7429a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/770044caa70465fbe5d2851a8d9a0bc0e5e7429a/tokio/src/sync/task/atomic_waker.rs
201
260
tokio-rs/tokio:tokio/src/sync/task/atomic_waker.rs:7
/// Wakes the task that last called `register`. /// /// If `register` has not been called yet, then this does nothing. pub(crate) fn wake(&self) { if let Some(waker) = self.take_waker() { waker.wake(); } } /// Attempts to take the `Waker` value out of the `AtomicWaker` w...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/task/atomic_waker.rs
MIT
770044caa70465fbe5d2851a8d9a0bc0e5e7429a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/770044caa70465fbe5d2851a8d9a0bc0e5e7429a/tokio/src/sync/task/atomic_waker.rs
241
300
tokio-rs/tokio:tokio/src/sync/task/atomic_waker.rs:8
} impl Default for AtomicWaker { fn default() -> Self { AtomicWaker::new() } } impl fmt::Debug for AtomicWaker { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { write!(fmt, "AtomicWaker") } } unsafe impl Send for AtomicWaker {} unsafe impl Sync for AtomicWaker {} trait W...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/task/atomic_waker.rs
MIT
770044caa70465fbe5d2851a8d9a0bc0e5e7429a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/770044caa70465fbe5d2851a8d9a0bc0e5e7429a/tokio/src/sync/task/atomic_waker.rs
281
321
tokio-rs/tokio:tokio/src/sync/task/atomic_waker.rs:4
// // 2) Call register before attempting to observe the application state. Since // Thread A still holds the `wake` lock, the call to `register` will result // in the task waking itself and get scheduled again. /// Idle state const WAITING: usize = 0; /// A new waker value is being registered with the `AtomicWa...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/task/atomic_waker.rs
MIT
a0557840eb424e174bf81a0175c40f9e176a2cc2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a0557840eb424e174bf81a0175c40f9e176a2cc2/tokio/src/sync/task/atomic_waker.rs
121
180
tokio-rs/tokio:tokio/src/sync/task/atomic_waker.rs:5
/// /// This function is safe to call concurrently, but this is generally a bad /// idea. Concurrent calls to `register` will attempt to register different /// tasks to be woken. One of the callers will win and have its task set, /// but there is no guarantee as to which caller will succeed. pub(cra...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/task/atomic_waker.rs
MIT
a0557840eb424e174bf81a0175c40f9e176a2cc2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a0557840eb424e174bf81a0175c40f9e176a2cc2/tokio/src/sync/task/atomic_waker.rs
161
220
tokio-rs/tokio:tokio/src/sync/task/atomic_waker.rs:6
// completed. let waker = self.waker.with_mut(|t| (*t).take()).unwrap(); // Just swap, because no one could change state // while state == `Registering | `Waking` self.state.swap(WAITING, AcqRel); ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/task/atomic_waker.rs
MIT
a0557840eb424e174bf81a0175c40f9e176a2cc2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a0557840eb424e174bf81a0175c40f9e176a2cc2/tokio/src/sync/task/atomic_waker.rs
201
260
tokio-rs/tokio:tokio/src/sync/task/atomic_waker.rs:7
if let Some(waker) = self.take_waker() { waker.wake(); } } /// Attempts to take the `Waker` value out of the `AtomicWaker` with the /// intention that the caller will wake the task later. pub(crate) fn take_waker(&self) -> Option<Waker> { // AcqRel ordering is used in order ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/task/atomic_waker.rs
MIT
a0557840eb424e174bf81a0175c40f9e176a2cc2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a0557840eb424e174bf81a0175c40f9e176a2cc2/tokio/src/sync/task/atomic_waker.rs
241
300
tokio-rs/tokio:tokio/src/sync/task/atomic_waker.rs:8
AtomicWaker::new() } } impl fmt::Debug for AtomicWaker { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { write!(fmt, "AtomicWaker") } } unsafe impl Send for AtomicWaker {} unsafe impl Sync for AtomicWaker {} trait WakerRef { fn wake(self); fn into_waker(self) -> Waker; } imp...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/task/atomic_waker.rs
MIT
a0557840eb424e174bf81a0175c40f9e176a2cc2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a0557840eb424e174bf81a0175c40f9e176a2cc2/tokio/src/sync/task/atomic_waker.rs
281
317
tokio-rs/tokio:tokio/src/sync/task/atomic_waker.rs:4
// // 2) Call register before attempting to observe the application state. Since // Thread A still holds the `wake` lock, the call to `register` will result // in the task waking itself and get scheduled again. /// Idle state const WAITING: usize = 0; /// A new waker value is being registered with the `AtomicWa...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/task/atomic_waker.rs
MIT
1cb1e291c10adf6b4e530cb1475b95ba10fa615f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1cb1e291c10adf6b4e530cb1475b95ba10fa615f/tokio/src/sync/task/atomic_waker.rs
121
180
tokio-rs/tokio:tokio/src/sync/task/atomic_waker.rs:5
/// task being woken once. /// /// This function is safe to call concurrently, but this is generally a bad /// idea. Concurrent calls to `register` will attempt to register different /// tasks to be woken. One of the callers will win and have its task set, /// but there is no guarantee as to which c...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/task/atomic_waker.rs
MIT
1cb1e291c10adf6b4e530cb1475b95ba10fa615f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1cb1e291c10adf6b4e530cb1475b95ba10fa615f/tokio/src/sync/task/atomic_waker.rs
161
220
tokio-rs/tokio:tokio/src/sync/task/atomic_waker.rs:6
// Take the waker to wake once the atomic operation has // completed. let waker = self.waker.with_mut(|t| (*t).take()).unwrap(); // Just swap, because no one could change state // while state == `Registering...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/task/atomic_waker.rs
MIT
1cb1e291c10adf6b4e530cb1475b95ba10fa615f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1cb1e291c10adf6b4e530cb1475b95ba10fa615f/tokio/src/sync/task/atomic_waker.rs
201
260
tokio-rs/tokio:tokio/src/sync/task/atomic_waker.rs:7
pub(crate) fn wake(&self) { if let Some(waker) = self.take_waker() { waker.wake(); } } /// Attempts to take the `Waker` value out of the `AtomicWaker` with the /// intention that the caller will wake the task later. pub(crate) fn take_waker(&self) -> Option<Waker> { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/task/atomic_waker.rs
MIT
1cb1e291c10adf6b4e530cb1475b95ba10fa615f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1cb1e291c10adf6b4e530cb1475b95ba10fa615f/tokio/src/sync/task/atomic_waker.rs
241
300
tokio-rs/tokio:tokio/src/sync/task/atomic_waker.rs:8
fn default() -> Self { AtomicWaker::new() } } impl fmt::Debug for AtomicWaker { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { write!(fmt, "AtomicWaker") } } unsafe impl Send for AtomicWaker {} unsafe impl Sync for AtomicWaker {} trait WakerRef { fn wake(self); fn in...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/task/atomic_waker.rs
MIT
1cb1e291c10adf6b4e530cb1475b95ba10fa615f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1cb1e291c10adf6b4e530cb1475b95ba10fa615f/tokio/src/sync/task/atomic_waker.rs
281
318
tokio-rs/tokio:tokio/src/sync/task/atomic_waker.rs:4
// // 2) Call register before attempting to observe the application state. Since // Thread A still holds the `wake` lock, the call to `register` will result // in the task waking itself and get scheduled again. /// Idle state const WAITING: usize = 0; /// A new waker value is being registered with the `AtomicWa...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/task/atomic_waker.rs
MIT
69975fb9601bbb21659db283d888470733bae660
github
async-runtime
https://github.com/tokio-rs/tokio/blob/69975fb9601bbb21659db283d888470733bae660/tokio/src/sync/task/atomic_waker.rs
121
180
tokio-rs/tokio:tokio/src/sync/task/atomic_waker.rs:4
// Thread A still holds the `wake` lock, the call to `register` will result // in the task waking itself and get scheduled again. /// Idle state const WAITING: usize = 0; /// A new waker value is being registered with the `AtomicWaker` cell. const REGISTERING: usize = 0b01; /// The task currently registered wi...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/task/atomic_waker.rs
MIT
0d38936b35779b604770120da2e98560bbb6241f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0d38936b35779b604770120da2e98560bbb6241f/tokio/src/sync/task/atomic_waker.rs
121
180
tokio-rs/tokio:tokio/src/sync/task/atomic_waker.rs:5
/// This function is safe to call concurrently, but this is generally a bad /// idea. Concurrent calls to `register` will attempt to register different /// tasks to be woken. One of the callers will win and have its task set, /// but there is no guarantee as to which caller will succeed. pub(crate) fn r...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/task/atomic_waker.rs
MIT
0d38936b35779b604770120da2e98560bbb6241f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0d38936b35779b604770120da2e98560bbb6241f/tokio/src/sync/task/atomic_waker.rs
161
220
tokio-rs/tokio:tokio/src/sync/task/atomic_waker.rs:6
let waker = self.waker.with_mut(|t| (*t).take()).unwrap(); // Just swap, because no one could change state // while state == `Registering | `Waking` self.state.swap(WAITING, AcqRel); // The atomic swap was ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/task/atomic_waker.rs
MIT
0d38936b35779b604770120da2e98560bbb6241f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0d38936b35779b604770120da2e98560bbb6241f/tokio/src/sync/task/atomic_waker.rs
201
260
tokio-rs/tokio:tokio/src/sync/task/atomic_waker.rs:7
waker.wake(); } } /// Attempts to take the `Waker` value out of the `AtomicWaker` with the /// intention that the caller will wake the task later. pub(crate) fn take_waker(&self) -> Option<Waker> { // AcqRel ordering is used in order to acquire the value of the `waker` // cell a...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/task/atomic_waker.rs
MIT
0d38936b35779b604770120da2e98560bbb6241f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0d38936b35779b604770120da2e98560bbb6241f/tokio/src/sync/task/atomic_waker.rs
241
300
tokio-rs/tokio:tokio/src/sync/task/atomic_waker.rs:8
} } impl fmt::Debug for AtomicWaker { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { write!(fmt, "AtomicWaker") } } unsafe impl Send for AtomicWaker {} unsafe impl Sync for AtomicWaker {} trait WakerRef { fn wake(self); fn into_waker(self) -> Waker; } impl WakerRef for Waker { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/task/atomic_waker.rs
MIT
0d38936b35779b604770120da2e98560bbb6241f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0d38936b35779b604770120da2e98560bbb6241f/tokio/src/sync/task/atomic_waker.rs
281
316
tokio-rs/tokio:tokio/src/sync/task/atomic_waker.rs:4
// Thread A still holds the `wake` lock, the call to `register` will result // in the task waking itself and get scheduled again. /// Idle state const WAITING: usize = 0; /// A new waker value is being registered with the `AtomicWaker` cell. const REGISTERING: usize = 0b01; /// The task currently registered wi...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/task/atomic_waker.rs
MIT
c147be04374534cf7062ea5e7062c4767ba0e2f7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c147be04374534cf7062ea5e7062c4767ba0e2f7/tokio/src/sync/task/atomic_waker.rs
121
180
tokio-rs/tokio:tokio/src/sync/task/atomic_waker.rs:5
/// This function is safe to call concurrently, but this is generally a bad /// idea. Concurrent calls to `register` will attempt to register different /// tasks to be woken. One of the callers will win and have its task set, /// but there is no guarantee as to which caller will succeed. pub(crate) fn r...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/task/atomic_waker.rs
MIT
c147be04374534cf7062ea5e7062c4767ba0e2f7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c147be04374534cf7062ea5e7062c4767ba0e2f7/tokio/src/sync/task/atomic_waker.rs
161
220
tokio-rs/tokio:tokio/src/sync/task/atomic_waker.rs:6
// Take the waker to wake once the atomic operation has // completed. let waker = self.waker.with_mut(|t| (*t).take()).unwrap(); // Just swap, because no one could change state // while state == `Registering...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/task/atomic_waker.rs
MIT
c147be04374534cf7062ea5e7062c4767ba0e2f7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c147be04374534cf7062ea5e7062c4767ba0e2f7/tokio/src/sync/task/atomic_waker.rs
201
260
tokio-rs/tokio:tokio/src/sync/task/atomic_waker.rs:7
/// If `register` has not been called yet, then this does nothing. pub(crate) fn wake(&self) { debug!(" + wake"); if let Some(waker) = self.take_waker() { waker.wake(); } } /// Attempts to take the `Waker` value out of the `AtomicWaker` with the /// intention that th...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/task/atomic_waker.rs
MIT
c147be04374534cf7062ea5e7062c4767ba0e2f7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c147be04374534cf7062ea5e7062c4767ba0e2f7/tokio/src/sync/task/atomic_waker.rs
241
300
tokio-rs/tokio:tokio/src/sync/task/atomic_waker.rs:8
} } } } impl Default for AtomicWaker { fn default() -> Self { AtomicWaker::new() } } impl fmt::Debug for AtomicWaker { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { write!(fmt, "AtomicWaker") } } unsafe impl Send for AtomicWaker {} unsafe impl Sync for Atomi...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/task/atomic_waker.rs
MIT
c147be04374534cf7062ea5e7062c4767ba0e2f7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c147be04374534cf7062ea5e7062c4767ba0e2f7/tokio/src/sync/task/atomic_waker.rs
281
324
tokio-rs/tokio:tokio/src/sync/task/atomic_waker.rs:4
// Thread A still holds the `wake` lock, the call to `register` will result // in the task waking itself and get scheduled again. /// Idle state const WAITING: usize = 0; /// A new waker value is being registered with the `AtomicWaker` cell. const REGISTERING: usize = 0b01; /// The task currently registered wi...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/task/atomic_waker.rs
MIT
a6253ed05a1e0d14bc64915f5937c29092df9497
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a6253ed05a1e0d14bc64915f5937c29092df9497/tokio/src/sync/task/atomic_waker.rs
121
180
tokio-rs/tokio:tokio/src/sync/task/atomic_waker.rs:5
/// idea. Concurrent calls to `register` will attempt to register different /// tasks to be woken. One of the callers will win and have its task set, /// but there is no guarantee as to which caller will succeed. pub fn register_by_ref(&self, waker: &Waker) { self.do_register(waker); } fn d...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/task/atomic_waker.rs
MIT
a6253ed05a1e0d14bc64915f5937c29092df9497
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a6253ed05a1e0d14bc64915f5937c29092df9497/tokio/src/sync/task/atomic_waker.rs
161
220
tokio-rs/tokio:tokio/src/sync/task/atomic_waker.rs:6
// completed. let waker = self.waker.with_mut(|t| (*t).take()).unwrap(); // Just swap, because no one could change state // while state == `Registering | `Waking` self.state.swap(WAITING, AcqRel); ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/task/atomic_waker.rs
MIT
a6253ed05a1e0d14bc64915f5937c29092df9497
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a6253ed05a1e0d14bc64915f5937c29092df9497/tokio/src/sync/task/atomic_waker.rs
201
260
tokio-rs/tokio:tokio/src/sync/task/atomic_waker.rs:7
pub fn wake(&self) { debug!(" + wake"); if let Some(waker) = self.take_waker() { waker.wake(); } } /// Attempts to take the `Waker` value out of the `AtomicWaker` with the /// intention that the caller will wake the task later. pub fn take_waker(&self) -> Option<Wake...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/task/atomic_waker.rs
MIT
a6253ed05a1e0d14bc64915f5937c29092df9497
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a6253ed05a1e0d14bc64915f5937c29092df9497/tokio/src/sync/task/atomic_waker.rs
241
300
tokio-rs/tokio:tokio/src/sync/tests/atomic_waker.rs:1
use crate::sync::AtomicWaker; use tokio_test::task; use std::task::Waker; #[allow(unused)] trait AssertSend: Send {} #[allow(unused)] trait AssertSync: Sync {} impl AssertSend for AtomicWaker {} impl AssertSync for AtomicWaker {} impl AssertSend for Waker {} impl AssertSync for Waker {} #[cfg(all(target_family = ...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/sync/tests/atomic_waker.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/tests/atomic_waker.rs
1
60
tokio-rs/tokio:tokio/src/sync/tests/atomic_waker.rs:2
#[test] #[cfg_attr(target_family = "wasm", ignore)] // threads not supported fn failed_wake_synchronizes() { for _ in 0..1000 { failed_wake_synchronizes_inner(); } } fn failed_wake_synchronizes_inner() { use futures::task::noop_waker_ref; use std::sync::atomic::{AtomicBool, Ordering}; stati...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/sync/tests/atomic_waker.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/tests/atomic_waker.rs
41
100
tokio-rs/tokio:tokio/src/sync/tests/atomic_waker.rs:3
static PANICKING_VTABLE: RawWakerVTable = RawWakerVTable::new( |_| panic!("clone"), |_| unimplemented!("wake"), |_| unimplemented!("wake_by_ref"), |_| (), ); static NONPANICKING_VTABLE: RawWakerVTable = RawWakerVTable::new( |_| RawWaker::new(ptr::null(), &NONPANICKING_VT...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/sync/tests/atomic_waker.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/tests/atomic_waker.rs
81
113
tokio-rs/tokio:tokio/src/sync/tests/atomic_waker.rs:1
use crate::sync::AtomicWaker; use tokio_test::task; use std::task::Waker; #[allow(unused)] trait AssertSend: Send {} #[allow(unused)] trait AssertSync: Sync {} impl AssertSend for AtomicWaker {} impl AssertSync for AtomicWaker {} impl AssertSend for Waker {} impl AssertSync for Waker {} #[cfg(all(target_family = ...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/sync/tests/atomic_waker.rs
MIT
be9328da75c34b14dbbf017c344fee6219985559
github
async-runtime
https://github.com/tokio-rs/tokio/blob/be9328da75c34b14dbbf017c344fee6219985559/tokio/src/sync/tests/atomic_waker.rs
1
60
tokio-rs/tokio:tokio/src/sync/tests/atomic_waker.rs:2
#[cfg(panic = "unwind")] #[test] #[cfg(not(target_family = "wasm"))] // wasm currently doesn't support unwinding fn atomic_waker_panic_safe() { use std::panic; use std::ptr; use std::task::{RawWaker, RawWakerVTable, Waker}; static PANICKING_VTABLE: RawWakerVTable = RawWakerVTable::new( |_| pani...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/sync/tests/atomic_waker.rs
MIT
be9328da75c34b14dbbf017c344fee6219985559
github
async-runtime
https://github.com/tokio-rs/tokio/blob/be9328da75c34b14dbbf017c344fee6219985559/tokio/src/sync/tests/atomic_waker.rs
41
81
tokio-rs/tokio:tokio/src/sync/tests/atomic_waker.rs:1
use crate::sync::AtomicWaker; use tokio_test::task; use std::task::Waker; trait AssertSend: Send {} trait AssertSync: Sync {} impl AssertSend for AtomicWaker {} impl AssertSync for AtomicWaker {} impl AssertSend for Waker {} impl AssertSync for Waker {} #[cfg(all(target_family = "wasm", not(target_os = "wasi")))] ...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/sync/tests/atomic_waker.rs
MIT
d8a4a5f24bfc5012071eec4e501bb4a58a1181d6
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d8a4a5f24bfc5012071eec4e501bb4a58a1181d6/tokio/src/sync/tests/atomic_waker.rs
1
60
tokio-rs/tokio:tokio/src/sync/tests/atomic_waker.rs:2
#[cfg(not(target_family = "wasm"))] // wasm currently doesn't support unwinding fn atomic_waker_panic_safe() { use std::panic; use std::ptr; use std::task::{RawWaker, RawWakerVTable, Waker}; static PANICKING_VTABLE: RawWakerVTable = RawWakerVTable::new( |_| panic!("clone"), |_| unimplem...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/sync/tests/atomic_waker.rs
MIT
d8a4a5f24bfc5012071eec4e501bb4a58a1181d6
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d8a4a5f24bfc5012071eec4e501bb4a58a1181d6/tokio/src/sync/tests/atomic_waker.rs
41
78
tokio-rs/tokio:tokio/src/sync/tests/atomic_waker.rs:1
use crate::sync::AtomicWaker; use tokio_test::task; use std::task::Waker; trait AssertSend: Send {} trait AssertSync: Sync {} impl AssertSend for AtomicWaker {} impl AssertSync for AtomicWaker {} impl AssertSend for Waker {} impl AssertSync for Waker {} #[cfg(all(target_family = "wasm", not(target_os = "wasi")))] ...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/sync/tests/atomic_waker.rs
MIT
c445e467ce4363b3a9b6825268814a9bc27c0127
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/src/sync/tests/atomic_waker.rs
1
60