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/mpsc/block.rs:10 | let new_block = Block::new(self.header.start_index + BLOCK_CAP);
let mut new_block = unsafe { NonNull::new_unchecked(Box::into_raw(new_block)) };
// Attempt to store the block. The first compare-and-swap attempt is
// "unrolled" due to minor differences in logic
//
// `AcqRel` ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/mpsc/block.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:11 | let mut curr = next;
// TODO: Should this iteration be capped?
loop {
let actual = unsafe { curr.as_ref().try_push(&mut new_block, AcqRel, Acquire) };
curr = match actual {
Ok(()) => {
return next;
}
Err(curr) ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/mpsc/block.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:12 | unsafe {
p.add(i).write(UnsafeCell::new(MaybeUninit::uninit()));
}
}
}
}
}
impl<T> ops::Index<usize> for Values<T> {
type Output = UnsafeCell<MaybeUninit<T>>;
fn index(&self, index: usize) -> &Self::Output {
self.0.index(index)
}
}
#[cfg... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/mpsc/block.rs | 441 | 472 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:4 | // Convert the pointer to a `Box`.
// Safety: The raw pointer was allocated using the global allocator, and with
// the layout for a `Block<T>`, so it's valid to convert it to box.
Box::from_raw(block.as_ptr())
}
}
/// Returns `true` if the block matches the given in... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | ebf61b45b5184018f00bc666887ebccf3d4fe51b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ebf61b45b5184018f00bc666887ebccf3d4fe51b/tokio/src/sync/mpsc/block.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:5 | return None;
}
// Get the value
let value = self.values[offset].with(|ptr| ptr::read(ptr));
Some(Read::Value(value.assume_init()))
}
/// Returns true if *this* block has a value in the given slot.
///
/// Always returns false when given an index from a different block.... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | ebf61b45b5184018f00bc666887ebccf3d4fe51b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ebf61b45b5184018f00bc666887ebccf3d4fe51b/tokio/src/sync/mpsc/block.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:6 | });
// Release the value. After this point, the slot ref may no longer
// be used. It is possible for the receiver to free the memory at
// any point.
self.set_ready(slot_offset);
}
/// Signal to the receiver that the sender half of the list is closed.
pub(crate) unsafe fn ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | ebf61b45b5184018f00bc666887ebccf3d4fe51b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ebf61b45b5184018f00bc666887ebccf3d4fe51b/tokio/src/sync/mpsc/block.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:7 | // tail_position is guaranteed to not access this block.
self.header
.observed_tail_position
.with_mut(|ptr| *ptr = tail_position);
// Set the released bit, signalling to the receiver that it is safe to
// free the block's memory as soon as all slots **prior** to
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | ebf61b45b5184018f00bc666887ebccf3d4fe51b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ebf61b45b5184018f00bc666887ebccf3d4fe51b/tokio/src/sync/mpsc/block.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:8 | let ret = NonNull::new(self.header.next.load(ordering));
debug_assert!(unsafe {
ret.map_or(true, |block| {
block.as_ref().header.start_index == self.header.start_index.wrapping_add(BLOCK_CAP)
})
});
ret
}
/// Pushes `block` as the next block in ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | ebf61b45b5184018f00bc666887ebccf3d4fe51b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ebf61b45b5184018f00bc666887ebccf3d4fe51b/tokio/src/sync/mpsc/block.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:9 | match NonNull::new(next_ptr) {
Some(next_ptr) => Err(next_ptr),
None => Ok(()),
}
}
/// Grows the `Block` linked list by allocating and appending a new block.
///
/// The next block in the linked list is returned. This may or may not be
/// the one allocated by the f... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | ebf61b45b5184018f00bc666887ebccf3d4fe51b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ebf61b45b5184018f00bc666887ebccf3d4fe51b/tokio/src/sync/mpsc/block.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:10 | // other threads acquiring the next pointer.
let next = NonNull::new(
self.header
.next
.compare_exchange(ptr::null_mut(), new_block.as_ptr(), AcqRel, Acquire)
.unwrap_or_else(|x| x),
);
let next = match next {
Some(next) =... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | ebf61b45b5184018f00bc666887ebccf3d4fe51b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ebf61b45b5184018f00bc666887ebccf3d4fe51b/tokio/src/sync/mpsc/block.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:11 | }
}
/// Returns `true` if the specified slot has a value ready to be consumed.
fn is_ready(bits: usize, slot: usize) -> bool {
let mask = 1 << slot;
mask == mask & bits
}
/// Returns `true` if the closed flag has been set.
fn is_tx_closed(bits: usize) -> bool {
TX_CLOSED == bits & TX_CLOSED
}
impl<T> Val... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | ebf61b45b5184018f00bc666887ebccf3d4fe51b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ebf61b45b5184018f00bc666887ebccf3d4fe51b/tokio/src/sync/mpsc/block.rs | 401 | 456 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:12 | #[cfg(all(test, not(loom)))]
#[test]
fn assert_no_stack_overflow() {
// https://github.com/tokio-rs/tokio/issues/5293
struct Foo {
_a: [u8; 2_000_000],
}
assert_eq!(
Layout::new::<MaybeUninit<Block<Foo>>>(),
Layout::new::<Block<Foo>>()
);
let _block = Block::<Foo>::new... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | ebf61b45b5184018f00bc666887ebccf3d4fe51b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ebf61b45b5184018f00bc666887ebccf3d4fe51b/tokio/src/sync/mpsc/block.rs | 441 | 456 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:6 | pub(crate) unsafe fn write(&self, slot_index: usize, value: T) {
// Get the offset into the block
let slot_offset = offset(slot_index);
self.values[slot_offset].with_mut(|ptr| {
// Safety: the caller guarantees that there is no concurrent access to the slot
unsafe {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | a708ad19cb9ae652d8a813554e68cb1d86593eb9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a708ad19cb9ae652d8a813554e68cb1d86593eb9/tokio/src/sync/mpsc/block.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:7 | }
/// Releases the block to the rx half for freeing.
///
/// This function is called by the tx half once it can be guaranteed that no
/// more senders will attempt to access the block.
///
/// # Safety
///
/// To maintain safety, the caller must ensure:
///
/// * The block will ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | a708ad19cb9ae652d8a813554e68cb1d86593eb9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a708ad19cb9ae652d8a813554e68cb1d86593eb9/tokio/src/sync/mpsc/block.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:8 | self.header.ready_slots.load(Acquire) & READY_MASK == READY_MASK
}
/// Returns the `observed_tail_position` value, if set
pub(crate) fn observed_tail_position(&self) -> Option<usize> {
if 0 == RELEASED & self.header.ready_slots.load(Acquire) {
None
} else {
Some(
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | a708ad19cb9ae652d8a813554e68cb1d86593eb9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a708ad19cb9ae652d8a813554e68cb1d86593eb9/tokio/src/sync/mpsc/block.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:9 | /// # Safety
///
/// To maintain safety, the caller must ensure:
///
/// * `block` is not freed until it has been removed from the list.
pub(crate) unsafe fn try_push(
&self,
block: &mut NonNull<Block<T>>,
success: Ordering,
failure: Ordering,
) -> Result<(), NonN... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | a708ad19cb9ae652d8a813554e68cb1d86593eb9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a708ad19cb9ae652d8a813554e68cb1d86593eb9/tokio/src/sync/mpsc/block.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:10 | /// the slots.
pub(crate) fn grow(&self) -> NonNull<Block<T>> {
// Create the new block. It is assumed that the block will become the
// next one after `&self`. If this turns out to not be the case,
// `start_index` is updated accordingly.
let new_block = Block::new(self.header.start... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | a708ad19cb9ae652d8a813554e68cb1d86593eb9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a708ad19cb9ae652d8a813554e68cb1d86593eb9/tokio/src/sync/mpsc/block.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:11 | // by repeatedly attempting to compare-and-swap the pointer into the
// `next` register until the compare-and-swap succeed.
//
// Care is taken to update new_block's start_index field as appropriate.
let mut curr = next;
// TODO: Should this iteration be capped?
loop {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | a708ad19cb9ae652d8a813554e68cb1d86593eb9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a708ad19cb9ae652d8a813554e68cb1d86593eb9/tokio/src/sync/mpsc/block.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:12 | unsafe fn initialize(_value: NonNull<Values<T>>) {
// When fuzzing, `UnsafeCell` needs to be initialized.
if_loom! {
let p = _value.as_ptr() as *mut UnsafeCell<MaybeUninit<T>>;
for i in 0..BLOCK_CAP {
unsafe {
p.add(i).write(UnsafeCell::new(May... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | a708ad19cb9ae652d8a813554e68cb1d86593eb9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a708ad19cb9ae652d8a813554e68cb1d86593eb9/tokio/src/sync/mpsc/block.rs | 441 | 477 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:4 | // Convert the pointer to a `Box`.
// Safety: The raw pointer was allocated using the global allocator, and with
// the layout for a `Block<T>`, so it's valid to convert it to box.
Box::from_raw(block.as_ptr())
}
}
/// Returns `true` if the block matches the given in... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | 665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d/tokio/src/sync/mpsc/block.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:5 | return None;
}
// Get the value
//
// Safety:
//
// 1. The caller guarantees that there is no concurrent access to the slot.
// 2. The `UnsafeCell` always give us a valid pointer to the value.
let value = self.values[offset].with(|ptr| unsafe { ptr::read(... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | 665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d/tokio/src/sync/mpsc/block.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:5 | return None;
}
// Get the value
let value = self.values[offset].with(|ptr| ptr::read(ptr));
Some(Read::Value(value.assume_init()))
}
/// Returns true if *this* block has a value in the given slot.
///
/// Always returns false when given an index from a different block.... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | dbf93c71844a01574a10f9dee0d4d9655a569f0a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/dbf93c71844a01574a10f9dee0d4d9655a569f0a/tokio/src/sync/mpsc/block.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:6 | });
// Release the value. After this point, the slot ref may no longer
// be used. It is possible for the receiver to free the memory at
// any point.
self.set_ready(slot_offset);
}
/// Signal to the receiver that the sender half of the list is closed.
pub(crate) unsafe fn ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | dbf93c71844a01574a10f9dee0d4d9655a569f0a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/dbf93c71844a01574a10f9dee0d4d9655a569f0a/tokio/src/sync/mpsc/block.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:7 | /// To maintain safety, the caller must ensure:
///
/// * The block will no longer be accessed by any sender.
pub(crate) unsafe fn tx_release(&self, tail_position: usize) {
// Track the observed tail_position. Any sender targeting a greater
// tail_position is guaranteed to not access this b... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | dbf93c71844a01574a10f9dee0d4d9655a569f0a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/dbf93c71844a01574a10f9dee0d4d9655a569f0a/tokio/src/sync/mpsc/block.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:8 | }
}
/// Loads the next block
pub(crate) fn load_next(&self, ordering: Ordering) -> Option<NonNull<Block<T>>> {
let ret = NonNull::new(self.header.next.load(ordering));
debug_assert!(unsafe {
ret.map_or(true, |block| {
block.as_ref().header.start_index == self.he... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | dbf93c71844a01574a10f9dee0d4d9655a569f0a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/dbf93c71844a01574a10f9dee0d4d9655a569f0a/tokio/src/sync/mpsc/block.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:9 | let next_ptr = self
.header
.next
.compare_exchange(ptr::null_mut(), block.as_ptr(), success, failure)
.unwrap_or_else(|x| x);
match NonNull::new(next_ptr) {
Some(next_ptr) => Err(next_ptr),
None => Ok(()),
}
}
/// Grows t... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | dbf93c71844a01574a10f9dee0d4d9655a569f0a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/dbf93c71844a01574a10f9dee0d4d9655a569f0a/tokio/src/sync/mpsc/block.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:10 | // If the compare-and-swap fails, then the actual value of the cell is
// returned from this function and accessed by the caller. Given this,
// the memory must be acquired.
//
// `Release` ensures that the newly allocated block is available to
// other threads acquiring the next... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | dbf93c71844a01574a10f9dee0d4d9655a569f0a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/dbf93c71844a01574a10f9dee0d4d9655a569f0a/tokio/src/sync/mpsc/block.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:11 | Err(curr) => curr,
};
crate::loom::thread::yield_now();
}
}
}
/// Returns `true` if the specified slot has a value ready to be consumed.
fn is_ready(bits: usize, slot: usize) -> bool {
let mask = 1 << slot;
mask == mask & bits
}
/// Returns `true` if the closed flag has be... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | dbf93c71844a01574a10f9dee0d4d9655a569f0a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/dbf93c71844a01574a10f9dee0d4d9655a569f0a/tokio/src/sync/mpsc/block.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:12 | fn index(&self, index: usize) -> &Self::Output {
self.0.index(index)
}
}
#[cfg(all(test, not(loom)))]
#[test]
fn assert_no_stack_overflow() {
// https://github.com/tokio-rs/tokio/issues/5293
struct Foo {
_a: [u8; 2_000_000],
}
assert_eq!(
Layout::new::<MaybeUninit<Block<Fo... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | dbf93c71844a01574a10f9dee0d4d9655a569f0a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/dbf93c71844a01574a10f9dee0d4d9655a569f0a/tokio/src/sync/mpsc/block.rs | 441 | 461 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:4 | // Convert the pointer to a `Box`.
// Safety: The raw pointer was allocated using the global allocator, and with
// the layout for a `Block<T>`, so it's valid to convert it to box.
Box::from_raw(block.as_ptr())
}
}
/// Returns `true` if the block matches the given in... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | 3ce4720a4532e40c78f7d851b1cfb8ea26542177 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3ce4720a4532e40c78f7d851b1cfb8ea26542177/tokio/src/sync/mpsc/block.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:5 | return None;
}
// Get the value
let value = self.values[offset].with(|ptr| ptr::read(ptr));
Some(Read::Value(value.assume_init()))
}
/// Returns true if there is a value in the slot to be consumed
///
/// # Safety
///
/// To maintain safety, the caller must ens... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | 3ce4720a4532e40c78f7d851b1cfb8ea26542177 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3ce4720a4532e40c78f7d851b1cfb8ea26542177/tokio/src/sync/mpsc/block.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:6 | // be used. It is possible for the receiver to free the memory at
// any point.
self.set_ready(slot_offset);
}
/// Signal to the receiver that the sender half of the list is closed.
pub(crate) unsafe fn tx_close(&self) {
self.header.ready_slots.fetch_or(TX_CLOSED, Release);
}
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | 3ce4720a4532e40c78f7d851b1cfb8ea26542177 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3ce4720a4532e40c78f7d851b1cfb8ea26542177/tokio/src/sync/mpsc/block.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:7 | pub(crate) unsafe fn tx_release(&self, tail_position: usize) {
// Track the observed tail_position. Any sender targeting a greater
// tail_position is guaranteed to not access this block.
self.header
.observed_tail_position
.with_mut(|ptr| *ptr = tail_position);
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | 3ce4720a4532e40c78f7d851b1cfb8ea26542177 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3ce4720a4532e40c78f7d851b1cfb8ea26542177/tokio/src/sync/mpsc/block.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:8 | /// Loads the next block
pub(crate) fn load_next(&self, ordering: Ordering) -> Option<NonNull<Block<T>>> {
let ret = NonNull::new(self.header.next.load(ordering));
debug_assert!(unsafe {
ret.map_or(true, |block| {
block.as_ref().header.start_index == self.header.start_in... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | 3ce4720a4532e40c78f7d851b1cfb8ea26542177 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3ce4720a4532e40c78f7d851b1cfb8ea26542177/tokio/src/sync/mpsc/block.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:9 | .compare_exchange(ptr::null_mut(), block.as_ptr(), success, failure)
.unwrap_or_else(|x| x);
match NonNull::new(next_ptr) {
Some(next_ptr) => Err(next_ptr),
None => Ok(()),
}
}
/// Grows the `Block` linked list by allocating and appending a new block.
//... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | 3ce4720a4532e40c78f7d851b1cfb8ea26542177 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3ce4720a4532e40c78f7d851b1cfb8ea26542177/tokio/src/sync/mpsc/block.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:10 | //
// `Release` ensures that the newly allocated block is available to
// other threads acquiring the next pointer.
let next = NonNull::new(
self.header
.next
.compare_exchange(ptr::null_mut(), new_block.as_ptr(), AcqRel, Acquire)
.unwr... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | 3ce4720a4532e40c78f7d851b1cfb8ea26542177 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3ce4720a4532e40c78f7d851b1cfb8ea26542177/tokio/src/sync/mpsc/block.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:11 | crate::loom::thread::yield_now();
}
}
}
/// Returns `true` if the specified slot has a value ready to be consumed.
fn is_ready(bits: usize, slot: usize) -> bool {
let mask = 1 << slot;
mask == mask & bits
}
/// Returns `true` if the closed flag has been set.
fn is_tx_closed(bits: usize) -> bool {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | 3ce4720a4532e40c78f7d851b1cfb8ea26542177 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3ce4720a4532e40c78f7d851b1cfb8ea26542177/tokio/src/sync/mpsc/block.rs | 401 | 458 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:12 | }
#[cfg(all(test, not(loom)))]
#[test]
fn assert_no_stack_overflow() {
// https://github.com/tokio-rs/tokio/issues/5293
struct Foo {
_a: [u8; 2_000_000],
}
assert_eq!(
Layout::new::<MaybeUninit<Block<Foo>>>(),
Layout::new::<Block<Foo>>()
);
let _block = Block::<Foo>::... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | 3ce4720a4532e40c78f7d851b1cfb8ea26542177 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3ce4720a4532e40c78f7d851b1cfb8ea26542177/tokio/src/sync/mpsc/block.rs | 441 | 458 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:4 | // Convert the pointer to a `Box`.
// Safety: The raw pointer was allocated using the global allocator, and with
// the layout for a `Block<T>`, so it's valid to convert it to box.
Box::from_raw(block.as_ptr())
}
}
/// Returns `true` if the block matches the given in... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | 5baa8d58ecca5f4b5c4fafe8ec030b8d0baa3ced | github | async-runtime | https://github.com/tokio-rs/tokio/blob/5baa8d58ecca5f4b5c4fafe8ec030b8d0baa3ced/tokio/src/sync/mpsc/block.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:5 | return None;
}
// Get the value
let value = self.values[offset].with(|ptr| ptr::read(ptr));
Some(Read::Value(value.assume_init()))
}
/// Writes a value to the block at the given offset.
///
/// # Safety
///
/// To maintain safety, the caller must ensure:
//... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | 5baa8d58ecca5f4b5c4fafe8ec030b8d0baa3ced | github | async-runtime | https://github.com/tokio-rs/tokio/blob/5baa8d58ecca5f4b5c4fafe8ec030b8d0baa3ced/tokio/src/sync/mpsc/block.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:6 | /// # Safety
///
/// To maintain safety, the caller must ensure:
///
/// * All slots are empty.
/// * The caller holds a unique pointer to the block.
pub(crate) unsafe fn reclaim(&mut self) {
self.header.start_index = 0;
self.header.next = AtomicPtr::new(ptr::null_mut());
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | 5baa8d58ecca5f4b5c4fafe8ec030b8d0baa3ced | github | async-runtime | https://github.com/tokio-rs/tokio/blob/5baa8d58ecca5f4b5c4fafe8ec030b8d0baa3ced/tokio/src/sync/mpsc/block.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:7 | /// Returns `true` when all slots have their `ready` bits set.
///
/// This indicates that the block is in its final state and will no longer
/// be mutated.
pub(crate) fn is_final(&self) -> bool {
self.header.ready_slots.load(Acquire) & READY_MASK == READY_MASK
}
/// Returns the `obser... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | 5baa8d58ecca5f4b5c4fafe8ec030b8d0baa3ced | github | async-runtime | https://github.com/tokio-rs/tokio/blob/5baa8d58ecca5f4b5c4fafe8ec030b8d0baa3ced/tokio/src/sync/mpsc/block.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:8 | /// This requires that the next pointer is null.
///
/// # Ordering
///
/// This performs a compare-and-swap on `next` using `AcqRel` ordering.
///
/// # Safety
///
/// To maintain safety, the caller must ensure:
///
/// * `block` is not freed until it has been removed from the l... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | 5baa8d58ecca5f4b5c4fafe8ec030b8d0baa3ced | github | async-runtime | https://github.com/tokio-rs/tokio/blob/5baa8d58ecca5f4b5c4fafe8ec030b8d0baa3ced/tokio/src/sync/mpsc/block.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:9 | /// with `AcqRel` memory ordering. If the compare-and-swap is successful, the
/// newly allocated block is released to other threads walking the block
/// linked list. If the compare-and-swap fails, the current thread acquires
/// the next block in the linked list, allowing the current thread to access
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | 5baa8d58ecca5f4b5c4fafe8ec030b8d0baa3ced | github | async-runtime | https://github.com/tokio-rs/tokio/blob/5baa8d58ecca5f4b5c4fafe8ec030b8d0baa3ced/tokio/src/sync/mpsc/block.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:10 | // There already is a next block in the linked list. The newly allocated
// block could be dropped and the discovered next block returned;
// however, that would be wasteful. Instead, the linked list is walked
// by repeatedly attempting to compare-and-swap the pointer into the
// `next`... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | 5baa8d58ecca5f4b5c4fafe8ec030b8d0baa3ced | github | async-runtime | https://github.com/tokio-rs/tokio/blob/5baa8d58ecca5f4b5c4fafe8ec030b8d0baa3ced/tokio/src/sync/mpsc/block.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:11 | ///
/// # Safety
///
/// The raw pointer must be valid for writing a `Values<T>`.
unsafe fn initialize(_value: NonNull<Values<T>>) {
// When fuzzing, `UnsafeCell` needs to be initialized.
if_loom! {
let p = _value.as_ptr() as *mut UnsafeCell<MaybeUninit<T>>;
for i... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | 5baa8d58ecca5f4b5c4fafe8ec030b8d0baa3ced | github | async-runtime | https://github.com/tokio-rs/tokio/blob/5baa8d58ecca5f4b5c4fafe8ec030b8d0baa3ced/tokio/src/sync/mpsc/block.rs | 401 | 440 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:6 | /// # Safety
///
/// To maintain safety, the caller must ensure:
///
/// * All slots are empty.
/// * The caller holds a unique pointer to the block.
pub(crate) unsafe fn reclaim(&mut self) {
self.header.start_index = 0;
self.header.next = AtomicPtr::new(ptr::null_mut());
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | 6871084629ad95c37c7136d865890ab2e371ea12 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/sync/mpsc/block.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:7 | /// Returns `true` when all slots have their `ready` bits set.
///
/// This indicates that the block is in its final state and will no longer
/// be mutated.
///
/// # Implementation
///
/// The implementation walks each slot checking the `ready` flag. It might
/// be that it would make ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | 6871084629ad95c37c7136d865890ab2e371ea12 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/sync/mpsc/block.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:8 | }
/// Pushes `block` as the next block in the link.
///
/// Returns Ok if successful, otherwise, a pointer to the next block in
/// the list is returned.
///
/// This requires that the next pointer is null.
///
/// # Ordering
///
/// This performs a compare-and-swap on `next` us... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | 6871084629ad95c37c7136d865890ab2e371ea12 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/sync/mpsc/block.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:9 | /// The next block in the linked list is returned. This may or may not be
/// the one allocated by the function call.
///
/// # Implementation
///
/// It is assumed that `self.next` is null. A new block is allocated with
/// `start_index` set to be the next block. A compare-and-swap is performed... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | 6871084629ad95c37c7136d865890ab2e371ea12 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/sync/mpsc/block.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:10 | Some(next) => next,
None => {
// The compare-and-swap succeeded and the newly allocated block
// is successfully pushed.
return new_block;
}
};
// There already is a next block in the linked list. The newly allocated
// blo... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | 6871084629ad95c37c7136d865890ab2e371ea12 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/sync/mpsc/block.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:11 | /// Returns `true` if the closed flag has been set.
fn is_tx_closed(bits: usize) -> bool {
TX_CLOSED == bits & TX_CLOSED
}
impl<T> Values<T> {
/// Initialize a `Values` struct from a pointer.
///
/// # Safety
///
/// The raw pointer must be valid for writing a `Values<T>`.
unsafe fn initial... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | 6871084629ad95c37c7136d865890ab2e371ea12 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/sync/mpsc/block.rs | 401 | 447 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:7 | /// Returns `true` when all slots have their `ready` bits set.
///
/// This indicates that the block is in its final state and will no longer
/// be mutated.
///
/// # Implementation
///
/// The implementation walks each slot checking the `ready` flag. It might
/// be that it would make ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | 81b50e946fe2f6b30de5e61356ab7cae560956a9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/81b50e946fe2f6b30de5e61356ab7cae560956a9/tokio/src/sync/mpsc/block.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:8 | ret
}
/// Pushes `block` as the next block in the link.
///
/// Returns Ok if successful, otherwise, a pointer to the next block in
/// the list is returned.
///
/// This requires that the next pointer is null.
///
/// # Ordering
///
/// This performs a compare-and-swap on `... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | 81b50e946fe2f6b30de5e61356ab7cae560956a9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/81b50e946fe2f6b30de5e61356ab7cae560956a9/tokio/src/sync/mpsc/block.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:9 | ///
/// The next block in the linked list is returned. This may or may not be
/// the one allocated by the function call.
///
/// # Implementation
///
/// It is assumed that `self.next` is null. A new block is allocated with
/// `start_index` set to be the next block. A compare-and-swap is p... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | 81b50e946fe2f6b30de5e61356ab7cae560956a9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/81b50e946fe2f6b30de5e61356ab7cae560956a9/tokio/src/sync/mpsc/block.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:10 | let next = match next {
Some(next) => next,
None => {
// The compare-and-swap succeeded and the newly allocated block
// is successfully pushed.
return new_block;
}
};
// There already is a next block in the linked list... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | 81b50e946fe2f6b30de5e61356ab7cae560956a9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/81b50e946fe2f6b30de5e61356ab7cae560956a9/tokio/src/sync/mpsc/block.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:1 | use crate::loom::cell::UnsafeCell;
use crate::loom::sync::atomic::{AtomicPtr, AtomicUsize};
use std::mem::MaybeUninit;
use std::ops;
use std::ptr::{self, NonNull};
use std::sync::atomic::Ordering::{self, AcqRel, Acquire, Release};
/// A block in a linked list.
///
/// Each block in the list can hold up to `BLOCK_CAP`... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | 03969cdae7674681d1b10926e6a56fbb8908dbb8 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/03969cdae7674681d1b10926e6a56fbb8908dbb8/tokio/src/sync/mpsc/block.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:2 | use super::BLOCK_CAP;
/// Masks an index to get the block identifier.
const BLOCK_MASK: usize = !(BLOCK_CAP - 1);
/// Masks an index to get the value offset in a block.
const SLOT_MASK: usize = BLOCK_CAP - 1;
/// Flag tracking that a block has gone through the sender's release routine.
///
/// When this is set, the ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | 03969cdae7674681d1b10926e6a56fbb8908dbb8 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/03969cdae7674681d1b10926e6a56fbb8908dbb8/tokio/src/sync/mpsc/block.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:3 | next: AtomicPtr::new(ptr::null_mut()),
ready_slots: AtomicUsize::new(0),
observed_tail_position: UnsafeCell::new(0),
// Value storage
values: unsafe { Values::uninitialized() },
}
}
/// Returns `true` if the block matches the given index.
pub(crate... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | 03969cdae7674681d1b10926e6a56fbb8908dbb8 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/03969cdae7674681d1b10926e6a56fbb8908dbb8/tokio/src/sync/mpsc/block.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:4 | if !is_ready(ready_bits, offset) {
if is_tx_closed(ready_bits) {
return Some(Read::Closed);
}
return None;
}
// Get the value
let value = self.values[offset].with(|ptr| ptr::read(ptr));
Some(Read::Value(value.assume_init()))
}
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | 03969cdae7674681d1b10926e6a56fbb8908dbb8 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/03969cdae7674681d1b10926e6a56fbb8908dbb8/tokio/src/sync/mpsc/block.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:5 | /// Resets the block to a blank state. This enables reusing blocks in the
/// channel.
///
/// # Safety
///
/// To maintain safety, the caller must ensure:
///
/// * All slots are empty.
/// * The caller holds a unique pointer to the block.
pub(crate) unsafe fn reclaim(&mut self) {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | 03969cdae7674681d1b10926e6a56fbb8908dbb8 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/03969cdae7674681d1b10926e6a56fbb8908dbb8/tokio/src/sync/mpsc/block.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:6 | let mask = 1 << slot;
self.ready_slots.fetch_or(mask, Release);
}
/// Returns `true` when all slots have their `ready` bits set.
///
/// This indicates that the block is in its final state and will no longer
/// be mutated.
///
/// # Implementation
///
/// The implementation... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | 03969cdae7674681d1b10926e6a56fbb8908dbb8 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/03969cdae7674681d1b10926e6a56fbb8908dbb8/tokio/src/sync/mpsc/block.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:7 | /// Pushes `block` as the next block in the link.
///
/// Returns Ok if successful, otherwise, a pointer to the next block in
/// the list is returned.
///
/// This requires that the next pointer is null.
///
/// # Ordering
///
/// This performs a compare-and-swap on `next` using Acq... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | 03969cdae7674681d1b10926e6a56fbb8908dbb8 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/03969cdae7674681d1b10926e6a56fbb8908dbb8/tokio/src/sync/mpsc/block.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:8 | /// # Implementation
///
/// It is assumed that `self.next` is null. A new block is allocated with
/// `start_index` set to be the next block. A compare-and-swap is performed
/// with AcqRel memory ordering. If the compare-and-swap is successful, the
/// newly allocated block is released to other th... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | 03969cdae7674681d1b10926e6a56fbb8908dbb8 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/03969cdae7674681d1b10926e6a56fbb8908dbb8/tokio/src/sync/mpsc/block.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:9 | return new_block;
}
};
// There already is a next block in the linked list. The newly allocated
// block could be dropped and the discovered next block returned;
// however, that would be wasteful. Instead, the linked list is walked
// by repeatedly attempting to com... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | 03969cdae7674681d1b10926e6a56fbb8908dbb8 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/03969cdae7674681d1b10926e6a56fbb8908dbb8/tokio/src/sync/mpsc/block.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:10 | impl<T> Values<T> {
unsafe fn uninitialized() -> Values<T> {
let mut vals = MaybeUninit::uninit();
// When fuzzing, `UnsafeCell` needs to be initialized.
if_loom! {
let p = vals.as_mut_ptr() as *mut UnsafeCell<MaybeUninit<T>>;
for i in 0..BLOCK_CAP {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | 03969cdae7674681d1b10926e6a56fbb8908dbb8 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/03969cdae7674681d1b10926e6a56fbb8908dbb8/tokio/src/sync/mpsc/block.rs | 361 | 385 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:1 | use crate::loom::cell::UnsafeCell;
use crate::loom::sync::atomic::{AtomicPtr, AtomicUsize};
use std::mem::MaybeUninit;
use std::ops;
use std::ptr::{self, NonNull};
use std::sync::atomic::Ordering::{self, AcqRel, Acquire, Release};
/// A block in a linked list.
///
/// Each block in the list can hold up to `BLOCK_CAP`... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | f1b89675eb621edc23a9aa31d625270307fb6ce9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f1b89675eb621edc23a9aa31d625270307fb6ce9/tokio/src/sync/mpsc/block.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:2 | use super::BLOCK_CAP;
/// Masks an index to get the block identifier
const BLOCK_MASK: usize = !(BLOCK_CAP - 1);
/// Masks an index to get the value offset in a block.
const SLOT_MASK: usize = BLOCK_CAP - 1;
/// Flag tracking that a block has gone through the sender's release routine.
///
/// When this is set, the r... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | f1b89675eb621edc23a9aa31d625270307fb6ce9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f1b89675eb621edc23a9aa31d625270307fb6ce9/tokio/src/sync/mpsc/block.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:3 | next: AtomicPtr::new(ptr::null_mut()),
ready_slots: AtomicUsize::new(0),
observed_tail_position: UnsafeCell::new(0),
// Value storage
values: unsafe { Values::uninitialized() },
}
}
/// Returns `true` if the block matches the given index
pub(crate)... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | f1b89675eb621edc23a9aa31d625270307fb6ce9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f1b89675eb621edc23a9aa31d625270307fb6ce9/tokio/src/sync/mpsc/block.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:9 | return new_block;
}
};
// There already is a next block in the linked list. The newly allocated
// block could be dropped and the discovered next block returned;
// however, that would be wasteful. Instead, the linked list is walked
// by repeatedly attempting to com... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | c4e56232ff844533320a5de4900d72d6c58ef220 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c4e56232ff844533320a5de4900d72d6c58ef220/tokio/src/sync/mpsc/block.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:10 | }
/// Returns `true` if the closed flag has been set.
fn is_tx_closed(bits: usize) -> bool {
TX_CLOSED == bits & TX_CLOSED
}
impl<T> Values<T> {
unsafe fn uninitialized() -> Values<T> {
let mut vals = MaybeUninit::uninit();
// When fuzzing, `UnsafeCell` needs to be initialized.
if_loo... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | c4e56232ff844533320a5de4900d72d6c58ef220 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c4e56232ff844533320a5de4900d72d6c58ef220/tokio/src/sync/mpsc/block.rs | 361 | 391 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:1 | use crate::loom::cell::UnsafeCell;
use crate::loom::sync::atomic::{AtomicPtr, AtomicUsize};
use crate::loom::thread;
use std::mem::MaybeUninit;
use std::ops;
use std::ptr::{self, NonNull};
use std::sync::atomic::Ordering::{self, AcqRel, Acquire, Release};
/// A block in a linked list.
///
/// Each block in the list c... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | 9a3603fa75ff854e007d372061edf47cf8d02690 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9a3603fa75ff854e007d372061edf47cf8d02690/tokio/src/sync/mpsc/block.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:2 | use super::BLOCK_CAP;
/// Masks an index to get the block identifier
const BLOCK_MASK: usize = !(BLOCK_CAP - 1);
/// Masks an index to get the value offset in a block.
const SLOT_MASK: usize = BLOCK_CAP - 1;
/// Flag tracking that a block has gone through the sender's release routine.
///
/// When this is set, the r... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | 9a3603fa75ff854e007d372061edf47cf8d02690 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9a3603fa75ff854e007d372061edf47cf8d02690/tokio/src/sync/mpsc/block.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:3 | // Pointer to the next block in the linked list.
next: AtomicPtr::new(ptr::null_mut()),
ready_slots: AtomicUsize::new(0),
observed_tail_position: UnsafeCell::new(0),
// Value storage
values: unsafe { Values::uninitialized() },
}
}
/// Retur... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | 9a3603fa75ff854e007d372061edf47cf8d02690 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9a3603fa75ff854e007d372061edf47cf8d02690/tokio/src/sync/mpsc/block.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:4 | if !is_ready(ready_bits, offset) {
if is_tx_closed(ready_bits) {
return Some(Read::Closed);
}
return None;
}
// Get the value
let value = self.values[offset].with(|ptr| ptr::read(ptr));
Some(Read::Value(value.assume_init()))
}
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | 9a3603fa75ff854e007d372061edf47cf8d02690 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9a3603fa75ff854e007d372061edf47cf8d02690/tokio/src/sync/mpsc/block.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:5 | }
/// Resets the block to a blank state. This enables reusing blocks in the
/// channel.
///
/// # Safety
///
/// To maintain safety, the caller must ensure:
///
/// * All slots are empty.
/// * The caller holds a unique pointer to the block.
pub(crate) unsafe fn reclaim(&mut se... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | 9a3603fa75ff854e007d372061edf47cf8d02690 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9a3603fa75ff854e007d372061edf47cf8d02690/tokio/src/sync/mpsc/block.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:6 | fn set_ready(&self, slot: usize) {
let mask = 1 << slot;
self.ready_slots.fetch_or(mask, Release);
}
/// Returns `true` when all slots have their `ready` bits set.
///
/// This indicates that the block is in its final state and will no longer
/// be mutated.
///
/// # Implem... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | 9a3603fa75ff854e007d372061edf47cf8d02690 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9a3603fa75ff854e007d372061edf47cf8d02690/tokio/src/sync/mpsc/block.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:7 | /// Pushes `block` as the next block in the link.
///
/// Returns Ok if successful, otherwise, a pointer to the next block in
/// the list is returned.
///
/// This requires that the next pointer is null.
///
/// # Ordering
///
/// This performs a compare-and-swap on `next` using Acq... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | 9a3603fa75ff854e007d372061edf47cf8d02690 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9a3603fa75ff854e007d372061edf47cf8d02690/tokio/src/sync/mpsc/block.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:8 | ///
/// # Implementation
///
/// It is assumed that `self.next` is null. A new block is allocated with
/// `start_index` set to be the next block. A compare-and-swap is performed
/// with AcqRel memory ordering. If the compare-and-swap is successful, the
/// newly allocated block is released to ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | 9a3603fa75ff854e007d372061edf47cf8d02690 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9a3603fa75ff854e007d372061edf47cf8d02690/tokio/src/sync/mpsc/block.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:9 | // is successfully pushed.
return new_block;
}
};
// There already is a next block in the linked list. The newly allocated
// block could be dropped and the discovered next block returned;
// however, that would be wasteful. Instead, the linked list is walked... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | 9a3603fa75ff854e007d372061edf47cf8d02690 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9a3603fa75ff854e007d372061edf47cf8d02690/tokio/src/sync/mpsc/block.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:10 | TX_CLOSED == bits & TX_CLOSED
}
impl<T> Values<T> {
unsafe fn uninitialized() -> Values<T> {
let mut vals = MaybeUninit::uninit();
// When fuzzing, `UnsafeCell` needs to be initialized.
if_loom! {
let p = vals.as_mut_ptr() as *mut UnsafeCell<MaybeUninit<T>>;
for i i... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | 9a3603fa75ff854e007d372061edf47cf8d02690 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9a3603fa75ff854e007d372061edf47cf8d02690/tokio/src/sync/mpsc/block.rs | 361 | 387 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:5 | }
/// Resets the block to a blank state. This enables reusing blocks in the
/// channel.
///
/// # Safety
///
/// To maintain safety, the caller must ensure:
///
/// * All slots are empty.
/// * The caller holds a unique pointer to the block.
pub(crate) unsafe fn reclaim(&mut se... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | 770044caa70465fbe5d2851a8d9a0bc0e5e7429a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/770044caa70465fbe5d2851a8d9a0bc0e5e7429a/tokio/src/sync/mpsc/block.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:9 | // is successfully pushed.
return new_block;
}
};
// There already is a next block in the linked list. The newly allocated
// block could be dropped and the discovered next block returned;
// however, that would be wasteful. Instead, the linked list is walked... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | 770044caa70465fbe5d2851a8d9a0bc0e5e7429a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/770044caa70465fbe5d2851a8d9a0bc0e5e7429a/tokio/src/sync/mpsc/block.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:7 | /// Pushes `block` as the next block in the link.
///
/// Returns Ok if successful, otherwise, a pointer to the next block in
/// the list is returned.
///
/// This requires that the next pointer is null.
///
/// # Ordering
///
/// This performs a compare-and-swap on `next` using Acq... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | 71da06097bf9aa851ebdde79d7b01a3e38174db9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/71da06097bf9aa851ebdde79d7b01a3e38174db9/tokio/src/sync/mpsc/block.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:8 | ///
/// It is assumed that `self.next` is null. A new block is allocated with
/// `start_index` set to be the next block. A compare-and-swap is performed
/// with AcqRel memory ordering. If the compare-and-swap is successful, the
/// newly allocated block is released to other threads walking the block
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | 71da06097bf9aa851ebdde79d7b01a3e38174db9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/71da06097bf9aa851ebdde79d7b01a3e38174db9/tokio/src/sync/mpsc/block.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:9 | }
};
// There already is a next block in the linked list. The newly allocated
// block could be dropped and the discovered next block returned;
// however, that would be wasteful. Instead, the linked list is walked
// by repeatedly attempting to compare-and-swap the pointer into... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | 71da06097bf9aa851ebdde79d7b01a3e38174db9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/71da06097bf9aa851ebdde79d7b01a3e38174db9/tokio/src/sync/mpsc/block.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:1 | use crate::loom::{
cell::UnsafeCell,
sync::atomic::{AtomicPtr, AtomicUsize},
thread,
};
use std::mem::MaybeUninit;
use std::ops;
use std::ptr::{self, NonNull};
use std::sync::atomic::Ordering::{self, AcqRel, Acquire, Release};
/// A block in a linked list.
///
/// Each block in the list can hold up to `BL... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | 1cb1e291c10adf6b4e530cb1475b95ba10fa615f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1cb1e291c10adf6b4e530cb1475b95ba10fa615f/tokio/src/sync/mpsc/block.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:2 | struct Values<T>([UnsafeCell<MaybeUninit<T>>; BLOCK_CAP]);
use super::BLOCK_CAP;
/// Masks an index to get the block identifier
const BLOCK_MASK: usize = !(BLOCK_CAP - 1);
/// Masks an index to get the value offset in a block.
const SLOT_MASK: usize = BLOCK_CAP - 1;
/// Flag tracking that a block has gone through t... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | 1cb1e291c10adf6b4e530cb1475b95ba10fa615f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1cb1e291c10adf6b4e530cb1475b95ba10fa615f/tokio/src/sync/mpsc/block.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:3 | start_index,
// Pointer to the next block in the linked list.
next: AtomicPtr::new(ptr::null_mut()),
ready_slots: AtomicUsize::new(0),
observed_tail_position: UnsafeCell::new(0),
// Value storage
values: unsafe { Values::uninitialized() },
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | 1cb1e291c10adf6b4e530cb1475b95ba10fa615f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1cb1e291c10adf6b4e530cb1475b95ba10fa615f/tokio/src/sync/mpsc/block.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:4 | let ready_bits = self.ready_slots.load(Acquire);
if !is_ready(ready_bits, offset) {
if is_tx_closed(ready_bits) {
return Some(Read::Closed);
}
return None;
}
// Get the value
let value = self.values[offset].with(|ptr| ptr::read(ptr))... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | 1cb1e291c10adf6b4e530cb1475b95ba10fa615f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1cb1e291c10adf6b4e530cb1475b95ba10fa615f/tokio/src/sync/mpsc/block.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:5 | pub(crate) unsafe fn tx_close(&self) {
self.ready_slots.fetch_or(TX_CLOSED, Release);
}
/// Resets the block to a blank state. This enables reusing blocks in the
/// channel.
///
/// # Safety
///
/// To maintain safety, the caller must ensure:
///
/// * All slots are empty.
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | 1cb1e291c10adf6b4e530cb1475b95ba10fa615f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1cb1e291c10adf6b4e530cb1475b95ba10fa615f/tokio/src/sync/mpsc/block.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:6 | /// Mark a slot as ready
fn set_ready(&self, slot: usize) {
let mask = 1 << slot;
self.ready_slots.fetch_or(mask, Release);
}
/// Returns `true` when all slots have their `ready` bits set.
///
/// This indicates that the block is in its final state and will no longer
/// be muta... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | 1cb1e291c10adf6b4e530cb1475b95ba10fa615f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1cb1e291c10adf6b4e530cb1475b95ba10fa615f/tokio/src/sync/mpsc/block.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:7 | ret
}
/// Pushes `block` as the next block in the link.
///
/// Returns Ok if successful, otherwise, a pointer to the next block in
/// the list is returned.
///
/// This requires that the next pointer is null.
///
/// # Ordering
///
/// This performs a compare-and-swap on `... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | 1cb1e291c10adf6b4e530cb1475b95ba10fa615f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1cb1e291c10adf6b4e530cb1475b95ba10fa615f/tokio/src/sync/mpsc/block.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:8 | ///
/// # Implementation
///
/// It is assumed that `self.next` is null. A new block is allocated with
/// `start_index` set to be the next block. A compare-and-swap is performed
/// with AcqRel memory ordering. If the compare-and-swap is successful, the
/// newly allocated block is released to ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | 1cb1e291c10adf6b4e530cb1475b95ba10fa615f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1cb1e291c10adf6b4e530cb1475b95ba10fa615f/tokio/src/sync/mpsc/block.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:9 | // is successfully pushed.
return new_block;
}
};
// There already is a next block in the linked list. The newly allocated
// block could be dropped and the discovered next block returned;
// however, that would be wasteful. Instead, the linked list is walked... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | 1cb1e291c10adf6b4e530cb1475b95ba10fa615f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1cb1e291c10adf6b4e530cb1475b95ba10fa615f/tokio/src/sync/mpsc/block.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:1 | use crate::loom::{
cell::CausalCell,
sync::atomic::{AtomicPtr, AtomicUsize},
thread,
};
use std::mem::MaybeUninit;
use std::ops;
use std::ptr::{self, NonNull};
use std::sync::atomic::Ordering::{self, AcqRel, Acquire, Release};
/// A block in a linked list.
///
/// Each block in the list can hold up to `BL... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | f9ddb93604a830d106475bd4c4cae436fafcc0da | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/sync/mpsc/block.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:2 | struct Values<T>([CausalCell<MaybeUninit<T>>; BLOCK_CAP]);
use super::BLOCK_CAP;
/// Masks an index to get the block identifier
const BLOCK_MASK: usize = !(BLOCK_CAP - 1);
/// Masks an index to get the value offset in a block.
const SLOT_MASK: usize = BLOCK_CAP - 1;
/// Flag tracking that a block has gone through t... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | f9ddb93604a830d106475bd4c4cae436fafcc0da | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/sync/mpsc/block.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:3 | start_index,
// Pointer to the next block in the linked list.
next: AtomicPtr::new(ptr::null_mut()),
ready_slots: AtomicUsize::new(0),
observed_tail_position: CausalCell::new(0),
// Value storage
values: unsafe { Values::uninitialized() },
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | f9ddb93604a830d106475bd4c4cae436fafcc0da | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/sync/mpsc/block.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:9 | // is successfully pushed.
return new_block;
}
};
// There already is a next block in the linked list. The newly allocated
// block could be dropped and the discovered next block returned;
// however, that would be wasteful. Instead, the linked list is walked... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | f9ddb93604a830d106475bd4c4cae436fafcc0da | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/sync/mpsc/block.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/sync/mpsc/block.rs:10 | TX_CLOSED == bits & TX_CLOSED
}
impl<T> Values<T> {
unsafe fn uninitialized() -> Values<T> {
let mut vals = MaybeUninit::uninit();
// When fuzzing, `CausalCell` needs to be initialized.
if_loom! {
let p = vals.as_mut_ptr() as *mut CausalCell<MaybeUninit<T>>;
for i i... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/block.rs | MIT | f9ddb93604a830d106475bd4c4cae436fafcc0da | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/sync/mpsc/block.rs | 361 | 387 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.