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/list.rs:2 | block_tail: AtomicPtr::new(initial_block_ptr),
tail_position: AtomicUsize::new(0),
};
let head = NonNull::new(initial_block_ptr).unwrap();
let rx = Rx {
head,
index: 0,
free_head: head,
};
(tx, rx)
}
impl<T> Tx<T> {
/// Pushes a value into the list.
pub(cr... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/list.rs | MIT | f9ddb93604a830d106475bd4c4cae436fafcc0da | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/sync/mpsc/list.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/sync/mpsc/list.rs:3 | let block = self.find_block(slot_index);
unsafe { block.as_ref().tx_close() }
}
fn find_block(&self, slot_index: usize) -> NonNull<Block<T>> {
// The start index of the block that contains `index`.
let start_index = block::start_index(slot_index);
// The index offset into the ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/list.rs | MIT | f9ddb93604a830d106475bd4c4cae436fafcc0da | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/sync/mpsc/list.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/sync/mpsc/list.rs:4 | let next_block = block
.load_next(Acquire)
// There is no allocated next block, grow the linked list.
.unwrap_or_else(|| block.grow());
// If the block is **not** final, then the tail pointer cannot be
// advanced any more.
try_updatin... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/list.rs | MIT | f9ddb93604a830d106475bd4c4cae436fafcc0da | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/sync/mpsc/list.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/sync/mpsc/list.rs:5 | try_updating_tail = false;
}
}
block_ptr = next_block.as_ptr();
thread::yield_now();
}
}
pub(crate) unsafe fn reclaim_block(&self, mut block: NonNull<Block<T>>) {
// The block has been removed from the linked list and ownership
// is... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/list.rs | MIT | f9ddb93604a830d106475bd4c4cae436fafcc0da | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/sync/mpsc/list.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/sync/mpsc/list.rs:6 | Err(next) => {
curr = next;
}
}
}
if !reused {
let _ = Box::from_raw(block.as_ptr());
}
}
}
impl<T> fmt::Debug for Tx<T> {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_struct("Tx")
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/list.rs | MIT | f9ddb93604a830d106475bd4c4cae436fafcc0da | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/sync/mpsc/list.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/sync/mpsc/list.rs:7 | ret
}
}
/// Tries advancing the block pointer to the block referenced by `self.index`.
///
/// Returns `true` if successful, `false` if there is no next block to load.
fn try_advancing_head(&mut self) -> bool {
let block_index = block::start_index(self.index);
loop {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/list.rs | MIT | f9ddb93604a830d106475bd4c4cae436fafcc0da | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/sync/mpsc/list.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/sync/mpsc/list.rs:8 | let observed_tail_position = block.as_ref().observed_tail_position();
let required_index = match observed_tail_position {
Some(i) => i,
None => return,
};
if required_index > self.index {
return;
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/list.rs | MIT | f9ddb93604a830d106475bd4c4cae436fafcc0da | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/sync/mpsc/list.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/sync/mpsc/list.rs:9 | // don't call `free_blocks` more than once.
self.free_head = NonNull::dangling();
self.head = NonNull::dangling();
}
while let Some(block) = cur {
cur = block.as_ref().load_next(Relaxed);
drop(Box::from_raw(block.as_ptr()));
}
}
}
impl<T> fmt... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/list.rs | MIT | f9ddb93604a830d106475bd4c4cae436fafcc0da | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/sync/mpsc/list.rs | 321 | 341 |
tokio-rs/tokio:tokio/src/sync/mpsc/list.rs:1 | //! A concurrent, lock-free, FIFO list.
use crate::loom::{
sync::atomic::{AtomicPtr, AtomicUsize},
thread,
};
use crate::sync::mpsc::block::{self, Block};
use std::fmt;
use std::ptr::NonNull;
use std::sync::atomic::Ordering::{AcqRel, Acquire, Relaxed, Release};
/// List queue transmit handle
pub(crate) struc... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/list.rs | MIT | 0d38936b35779b604770120da2e98560bbb6241f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0d38936b35779b604770120da2e98560bbb6241f/tokio/src/sync/mpsc/list.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/sync/mpsc/list.rs:2 | block_tail: AtomicPtr::new(initial_block_ptr),
tail_position: AtomicUsize::new(0),
};
let head = NonNull::new(initial_block_ptr).unwrap();
let rx = Rx {
head,
index: 0,
free_head: head,
};
(tx, rx)
}
impl<T> Tx<T> {
/// Push a value into the list.
pub(crat... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/list.rs | MIT | 0d38936b35779b604770120da2e98560bbb6241f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0d38936b35779b604770120da2e98560bbb6241f/tokio/src/sync/mpsc/list.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/sync/mpsc/list.rs:6 | Err(next) => {
curr = next;
}
}
}
if !reused {
let _ = Box::from_raw(block.as_ptr());
}
}
}
impl<T> fmt::Debug for Tx<T> {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_struct("Tx")
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/list.rs | MIT | 0d38936b35779b604770120da2e98560bbb6241f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0d38936b35779b604770120da2e98560bbb6241f/tokio/src/sync/mpsc/list.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/sync/mpsc/list.rs:7 | ret
}
}
/// Try advancing the block pointer to the block referenced by `self.index`.
///
/// Returns `true` if successful, `false` if there is no next block to load.
fn try_advancing_head(&mut self) -> bool {
let block_index = block::start_index(self.index);
loop {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/list.rs | MIT | 0d38936b35779b604770120da2e98560bbb6241f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0d38936b35779b604770120da2e98560bbb6241f/tokio/src/sync/mpsc/list.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/sync/mpsc/list.rs:4 | let next_block = block
.load_next(Acquire)
// There is no allocated next block, grow the linked list.
.unwrap_or_else(|| block.grow());
// If the block is **not** final, then the tail pointer cannot be
// advanced any more.
try_updatin... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/list.rs | MIT | a6253ed05a1e0d14bc64915f5937c29092df9497 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a6253ed05a1e0d14bc64915f5937c29092df9497/tokio/src/sync/mpsc/list.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/sync/mpsc/list.rs:5 | try_updating_tail = false;
}
}
block_ptr = next_block.as_ptr();
thread::yield_now();
}
}
pub(crate) unsafe fn reclaim_block(&self, mut block: NonNull<Block<T>>) {
debug!("+ reclaim_block({:p})", block);
// The block has been removed ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/list.rs | MIT | a6253ed05a1e0d14bc64915f5937c29092df9497 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a6253ed05a1e0d14bc64915f5937c29092df9497/tokio/src/sync/mpsc/list.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/sync/mpsc/list.rs:6 | }
Err(next) => {
curr = next;
}
}
}
if !reused {
debug!(" + block freed {:p}", block);
let _ = Box::from_raw(block.as_ptr());
}
}
}
impl<T> fmt::Debug for Tx<T> {
fn fmt(&self, fmt: &mut fmt::Format... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/list.rs | MIT | a6253ed05a1e0d14bc64915f5937c29092df9497 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a6253ed05a1e0d14bc64915f5937c29092df9497/tokio/src/sync/mpsc/list.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/sync/mpsc/list.rs:7 | self.index = self.index.wrapping_add(1);
}
ret
}
}
/// Try advancing the block pointer to the block referenced by `self.index`.
///
/// Returns `true` if successful, `false` if there is no next block to load.
fn try_advancing_head(&mut self) -> bool {
let bl... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/list.rs | MIT | a6253ed05a1e0d14bc64915f5937c29092df9497 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a6253ed05a1e0d14bc64915f5937c29092df9497/tokio/src/sync/mpsc/list.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/sync/mpsc/list.rs:8 | while self.free_head != self.head {
unsafe {
// Get a handle to the block that will be freed and update
// `free_head` to point to the next block.
let block = self.free_head;
let observed_tail_position = block.as_ref().observed_tail_position()... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/list.rs | MIT | a6253ed05a1e0d14bc64915f5937c29092df9497 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a6253ed05a1e0d14bc64915f5937c29092df9497/tokio/src/sync/mpsc/list.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/sync/mpsc/list.rs:9 | let mut cur = Some(self.free_head);
#[cfg(debug_assertions)]
{
// to trigger the debug assert above so as to catch that we
// don't call `free_blocks` more than once.
self.free_head = NonNull::dangling();
self.head = NonNull::dangling();
}
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/list.rs | MIT | a6253ed05a1e0d14bc64915f5937c29092df9497 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a6253ed05a1e0d14bc64915f5937c29092df9497/tokio/src/sync/mpsc/list.rs | 321 | 348 |
tokio-rs/tokio:tokio/src/sync/mpsc/mod.rs:1 | #![cfg_attr(not(feature = "sync"), allow(dead_code, unreachable_pub))]
//! A multi-producer, single-consumer queue for sending values across
//! asynchronous tasks.
//!
//! Similar to `std`, channel creation provides [`Receiver`] and [`Sender`]
//! handles. [`Receiver`] implements `Stream` and allows a task to read va... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/mod.rs | MIT | 31315b94638d8d5912c5f8321d365fd6a210a060 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/31315b94638d8d5912c5f8321d365fd6a210a060/tokio/src/sync/mpsc/mod.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/sync/mpsc/mod.rs:2 | pub use self::bounded::{channel, Receiver, Sender};
mod chan;
pub(super) mod list;
mod unbounded;
pub use self::unbounded::{unbounded_channel, UnboundedReceiver, UnboundedSender};
pub mod error;
/// The number of values a block can contain.
///
/// This value must be a power of 2. It also must be smaller than the ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/mod.rs | MIT | 31315b94638d8d5912c5f8321d365fd6a210a060 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/31315b94638d8d5912c5f8321d365fd6a210a060/tokio/src/sync/mpsc/mod.rs | 41 | 63 |
tokio-rs/tokio:tokio/src/sync/mpsc/mod.rs:1 | #![cfg_attr(not(feature = "sync"), allow(dead_code, unreachable_pub))]
//! A multi-producer, single-consumer queue for sending values across
//! asynchronous tasks.
//!
//! Similar to `std`, channel creation provides [`Receiver`] and [`Sender`]
//! handles. [`Receiver`] implements `Stream` and allows a task to read va... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/mod.rs | MIT | 7b53b7b659fe1feeb30e768cad8fdadf9531beb6 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7b53b7b659fe1feeb30e768cad8fdadf9531beb6/tokio/src/sync/mpsc/mod.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/sync/mpsc/mod.rs:2 | mod bounded;
pub use self::bounded::{channel, Receiver, Sender};
mod chan;
pub(super) mod list;
mod unbounded;
pub use self::unbounded::{unbounded_channel, UnboundedReceiver, UnboundedSender};
pub mod error;
/// The number of values a block can contain.
///
/// This value must be a power of 2. It also must be smal... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/mod.rs | MIT | 7b53b7b659fe1feeb30e768cad8fdadf9531beb6 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7b53b7b659fe1feeb30e768cad8fdadf9531beb6/tokio/src/sync/mpsc/mod.rs | 41 | 64 |
tokio-rs/tokio:tokio/src/sync/mpsc/mod.rs:1 | #![cfg_attr(not(feature = "sync"), allow(dead_code, unreachable_pub))]
//! A multi-producer, single-consumer queue for sending values across
//! asynchronous tasks.
//!
//! Similar to `std`, channel creation provides [`Receiver`] and [`Sender`]
//! handles. [`Receiver`] implements `Stream` and allows a task to read va... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/mod.rs | MIT | 0d38936b35779b604770120da2e98560bbb6241f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0d38936b35779b604770120da2e98560bbb6241f/tokio/src/sync/mpsc/mod.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/sync/mpsc/mod.rs:1 | //! A multi-producer, single-consumer queue for sending values across
//! asynchronous tasks.
//!
//! Similar to `std`, channel creation provides [`Receiver`] and [`Sender`]
//! handles. [`Receiver`] implements `Stream` and allows a task to read values
//! out of the channel. If there is no message to read, the current... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/mod.rs | MIT | 8a7e57786a5dca139f5b4261685e22991ded0859 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8a7e57786a5dca139f5b4261685e22991ded0859/tokio/src/sync/mpsc/mod.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/sync/mpsc/mod.rs:2 | mod chan;
pub(super) mod list;
mod unbounded;
pub use self::unbounded::{unbounded_channel, UnboundedReceiver, UnboundedSender};
pub mod error;
/// The number of values a block can contain.
///
/// This value must be a power of 2. It also must be smaller than the number of
/// bits in `usize`.
#[cfg(all(target_point... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/mod.rs | MIT | 8a7e57786a5dca139f5b4261685e22991ded0859 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8a7e57786a5dca139f5b4261685e22991ded0859/tokio/src/sync/mpsc/mod.rs | 41 | 62 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:1 | use crate::loom::sync::{atomic::AtomicUsize, Arc};
use crate::sync::mpsc::chan;
use crate::sync::mpsc::error::{SendError, TryRecvError};
use std::fmt;
use std::task::{Context, Poll};
/// Send values to the associated `UnboundedReceiver`.
///
/// Instances are created by the [`unbounded_channel`] function.
pub struct ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/mpsc/unbounded.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:2 | /// drop(tx);
/// assert!(tx_weak.clone().upgrade().is_none());
/// # }
/// ```
pub struct WeakUnboundedSender<T> {
chan: Arc<chan::Chan<T, Semaphore>>,
}
impl<T> Clone for UnboundedSender<T> {
fn clone(&self) -> Self {
UnboundedSender {
chan: self.chan.clone(),
}
}
}
impl<T> f... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/mpsc/unbounded.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:3 | .finish()
}
}
/// Creates an unbounded mpsc channel for communicating between asynchronous
/// tasks without backpressure.
///
/// A `send` on this channel will always succeed as long as the receive half has
/// not been closed. If the receiver falls behind, messages will be arbitrarily
/// buffered.
///
/// **Not... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/mpsc/unbounded.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:8 | ///
/// assert_eq!(Ok("hello"), rx.try_recv());
/// assert_eq!(Err(TryRecvError::Disconnected), rx.try_recv());
/// # }
/// ```
pub fn try_recv(&mut self) -> Result<T, TryRecvError> {
self.chan.try_recv()
}
/// Blocking receive to call outside of asynchronous contexts.
///
/... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/mpsc/unbounded.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:9 | pub fn blocking_recv(&mut self) -> Option<T> {
crate::future::block_on(self.recv())
}
/// Variant of [`Self::recv_many`] for blocking contexts.
///
/// The same conditions as in [`Self::blocking_recv`] apply.
#[track_caller]
#[cfg(feature = "sync")]
#[cfg_attr(docsrs, doc(alias = "r... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/mpsc/unbounded.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:13 | /// match receiver.poll_recv_many(cx, *buffer, *limit) {
/// Poll::Pending => Poll::Pending,
/// Poll::Ready(count) => Poll::Ready(count),
/// }
/// }
/// }
///
/// # #[tokio::main(flavor = "current_thread")]
/// # async fn main() {
/// let... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/mpsc/unbounded.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:14 | }
/// Returns the number of [`WeakUnboundedSender`] handles.
pub fn sender_weak_count(&self) -> usize {
self.chan.sender_weak_count()
}
}
impl<T> UnboundedSender<T> {
pub(crate) fn new(chan: chan::Tx<T, Semaphore>) -> UnboundedSender<T> {
UnboundedSender { chan }
}
/// Attempt... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/mpsc/unbounded.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:15 | loop {
if curr & 1 == 1 {
return false;
}
if curr == usize::MAX ^ 1 {
// Overflowed the ref count. There is no safe way to recover, so
// abort the process. In practice, this should never happen.
process::abort()
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/mpsc/unbounded.rs | 561 | 620 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:17 | /// drop(rx);
/// assert!(tx.is_closed());
/// assert!(tx2.is_closed());
/// ```
pub fn is_closed(&self) -> bool {
self.chan.is_closed()
}
/// Returns `true` if senders belong to the same channel.
///
/// # Examples
///
/// ```
/// let (tx, rx) = tokio::sync::mpsc::u... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/mpsc/unbounded.rs | 641 | 700 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:18 | /// Returns the number of [`WeakUnboundedSender`] handles.
pub fn weak_count(&self) -> usize {
self.chan.weak_count()
}
}
impl<T> Clone for WeakUnboundedSender<T> {
fn clone(&self) -> Self {
self.chan.increment_weak_count();
WeakUnboundedSender {
chan: self.chan.clone()... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/mpsc/unbounded.rs | 681 | 726 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:13 | /// match receiver.poll_recv_many(cx, *buffer, *limit) {
/// Poll::Pending => Poll::Pending,
/// Poll::Ready(count) => Poll::Ready(count),
/// }
/// }
/// }
///
/// # #[tokio::main(flavor = "current_thread")]
/// # async fn main() {
/// let... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d/tokio/src/sync/mpsc/unbounded.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:14 | }
/// Returns the number of [`WeakUnboundedSender`] handles.
pub fn sender_weak_count(&self) -> usize {
self.chan.sender_weak_count()
}
}
impl<T> UnboundedSender<T> {
pub(crate) fn new(chan: chan::Tx<T, Semaphore>) -> UnboundedSender<T> {
UnboundedSender { chan }
}
/// Attempt... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d/tokio/src/sync/mpsc/unbounded.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:15 | loop {
if curr & 1 == 1 {
return false;
}
if curr == usize::MAX ^ 1 {
// Overflowed the ref count. There is no safe way to recover, so
// abort the process. In practice, this should never happen.
process::abort()
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d/tokio/src/sync/mpsc/unbounded.rs | 561 | 620 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:17 | /// assert!(tx.is_closed());
/// assert!(tx2.is_closed());
/// ```
pub fn is_closed(&self) -> bool {
self.chan.is_closed()
}
/// Returns `true` if senders belong to the same channel.
///
/// # Examples
///
/// ```
/// let (tx, rx) = tokio::sync::mpsc::unbounded_channel::... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d/tokio/src/sync/mpsc/unbounded.rs | 641 | 700 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:18 | pub fn weak_count(&self) -> usize {
self.chan.weak_count()
}
}
impl<T> Clone for WeakUnboundedSender<T> {
fn clone(&self) -> Self {
self.chan.increment_weak_count();
WeakUnboundedSender {
chan: self.chan.clone(),
}
}
}
impl<T> Drop for WeakUnboundedSender<T> {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d/tokio/src/sync/mpsc/unbounded.rs | 681 | 725 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:1 | use crate::loom::sync::{atomic::AtomicUsize, Arc};
use crate::sync::mpsc::chan;
use crate::sync::mpsc::error::{SendError, TryRecvError};
use std::fmt;
use std::task::{Context, Poll};
/// Send values to the associated `UnboundedReceiver`.
///
/// Instances are created by the [`unbounded_channel`] function.
pub struct ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 1656d8e231903a7b84b9e2d5e3db7aeed13a2966 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1656d8e231903a7b84b9e2d5e3db7aeed13a2966/tokio/src/sync/mpsc/unbounded.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:2 | /// drop(tx);
/// assert!(tx_weak.clone().upgrade().is_none());
/// }
/// ```
pub struct WeakUnboundedSender<T> {
chan: Arc<chan::Chan<T, Semaphore>>,
}
impl<T> Clone for UnboundedSender<T> {
fn clone(&self) -> Self {
UnboundedSender {
chan: self.chan.clone(),
}
}
}
imp... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 1656d8e231903a7b84b9e2d5e3db7aeed13a2966 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1656d8e231903a7b84b9e2d5e3db7aeed13a2966/tokio/src/sync/mpsc/unbounded.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:3 | .finish()
}
}
/// Creates an unbounded mpsc channel for communicating between asynchronous
/// tasks without backpressure.
///
/// A `send` on this channel will always succeed as long as the receive half has
/// not been closed. If the receiver falls behind, messages will be arbitrarily
/// buffered.
///
/// **Not... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 1656d8e231903a7b84b9e2d5e3db7aeed13a2966 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1656d8e231903a7b84b9e2d5e3db7aeed13a2966/tokio/src/sync/mpsc/unbounded.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:8 | ///
/// assert_eq!(Ok("hello"), rx.try_recv());
/// assert_eq!(Err(TryRecvError::Disconnected), rx.try_recv());
/// }
/// ```
pub fn try_recv(&mut self) -> Result<T, TryRecvError> {
self.chan.try_recv()
}
/// Blocking receive to call outside of asynchronous contexts.
///... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 1656d8e231903a7b84b9e2d5e3db7aeed13a2966 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1656d8e231903a7b84b9e2d5e3db7aeed13a2966/tokio/src/sync/mpsc/unbounded.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:13 | /// }
///
/// #[tokio::main]
/// async fn main() {
/// let (tx, rx) = mpsc::unbounded_channel::<i32>();
/// let mut buffer = Vec::new();
///
/// let my_receiver_future = MyReceiverFuture {
/// receiver: rx,
/// buffer: &mut buffer,
/// limit: 3... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 1656d8e231903a7b84b9e2d5e3db7aeed13a2966 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1656d8e231903a7b84b9e2d5e3db7aeed13a2966/tokio/src/sync/mpsc/unbounded.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:14 | }
impl<T> UnboundedSender<T> {
pub(crate) fn new(chan: chan::Tx<T, Semaphore>) -> UnboundedSender<T> {
UnboundedSender { chan }
}
/// Attempts to send a message on this `UnboundedSender` without blocking.
///
/// This method is not marked async because sending a message to an unbounded cha... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 1656d8e231903a7b84b9e2d5e3db7aeed13a2966 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1656d8e231903a7b84b9e2d5e3db7aeed13a2966/tokio/src/sync/mpsc/unbounded.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:15 | // Overflowed the ref count. There is no safe way to recover, so
// abort the process. In practice, this should never happen.
process::abort()
}
match self
.chan
.semaphore()
.0
.compare_exchange(cur... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 1656d8e231903a7b84b9e2d5e3db7aeed13a2966 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1656d8e231903a7b84b9e2d5e3db7aeed13a2966/tokio/src/sync/mpsc/unbounded.rs | 561 | 620 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:17 | /// Returns `true` if senders belong to the same channel.
///
/// # Examples
///
/// ```
/// let (tx, rx) = tokio::sync::mpsc::unbounded_channel::<()>();
/// let tx2 = tx.clone();
/// assert!(tx.same_channel(&tx2));
///
/// let (tx3, rx3) = tokio::sync::mpsc::unbounded_channel::<()>... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 1656d8e231903a7b84b9e2d5e3db7aeed13a2966 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1656d8e231903a7b84b9e2d5e3db7aeed13a2966/tokio/src/sync/mpsc/unbounded.rs | 641 | 700 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:18 | fn clone(&self) -> Self {
self.chan.increment_weak_count();
WeakUnboundedSender {
chan: self.chan.clone(),
}
}
}
impl<T> Drop for WeakUnboundedSender<T> {
fn drop(&mut self) {
self.chan.decrement_weak_count();
}
}
impl<T> WeakUnboundedSender<T> {
/// Tries ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 1656d8e231903a7b84b9e2d5e3db7aeed13a2966 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1656d8e231903a7b84b9e2d5e3db7aeed13a2966/tokio/src/sync/mpsc/unbounded.rs | 681 | 719 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:13 | /// limit: 3,
/// };
///
/// for i in 0..10 {
/// tx.send(i).expect("Unable to send integer");
/// }
///
/// let count = my_receiver_future.await;
/// assert_eq!(count, 3);
/// assert_eq!(buffer, vec![0,1,2])
/// }
/// ```
pub fn po... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/src/sync/mpsc/unbounded.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:14 | /// never requires any form of waiting. Because of this, the `send` method can be
/// used in both synchronous and asynchronous code without problems.
///
/// If the receive half of the channel is closed, either due to [`close`]
/// being called or the [`UnboundedReceiver`] having been dropped, this
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/src/sync/mpsc/unbounded.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:16 | /// tx5.closed()
/// );
//// println!("Receiver dropped");
/// }
/// ```
pub async fn closed(&self) {
self.chan.closed().await;
}
/// Checks if the channel has been closed. This happens when the
/// [`UnboundedReceiver`] is dropped, or when the
/// [`Unbounde... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/src/sync/mpsc/unbounded.rs | 601 | 660 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:17 | /// let (tx3, rx3) = tokio::sync::mpsc::unbounded_channel::<()>();
/// assert!(!tx3.same_channel(&tx2));
/// ```
pub fn same_channel(&self, other: &Self) -> bool {
self.chan.same_channel(&other.chan)
}
/// Converts the `UnboundedSender` to a [`WeakUnboundedSender`] that does not count
/... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/src/sync/mpsc/unbounded.rs | 641 | 700 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:18 | fn drop(&mut self) {
self.chan.decrement_weak_count();
}
}
impl<T> WeakUnboundedSender<T> {
/// Tries to convert a `WeakUnboundedSender` into an [`UnboundedSender`].
/// This will return `Some` if there are other `Sender` instances alive and
/// the channel wasn't previously dropped, otherwise ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/src/sync/mpsc/unbounded.rs | 681 | 709 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:13 | /// limit: 3,
/// };
///
/// for i in 0..10 {
/// tx.send(i).expect("Unable to send integer");
/// }
///
/// let count = my_receiver_future.await;
/// assert_eq!(count, 3);
/// assert_eq!(buffer, vec![0,1,2])
/// }
/// ```
pub fn po... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 3ce4720a4532e40c78f7d851b1cfb8ea26542177 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3ce4720a4532e40c78f7d851b1cfb8ea26542177/tokio/src/sync/mpsc/unbounded.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:14 | if !self.inc_num_messages() {
return Err(SendError(message));
}
self.chan.send(message);
Ok(())
}
fn inc_num_messages(&self) -> bool {
use std::process;
use std::sync::atomic::Ordering::{AcqRel, Acquire};
let mut curr = self.chan.semaphore().0.load(... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 3ce4720a4532e40c78f7d851b1cfb8ea26542177 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3ce4720a4532e40c78f7d851b1cfb8ea26542177/tokio/src/sync/mpsc/unbounded.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:16 | /// [`UnboundedReceiver`] is dropped, or when the
/// [`UnboundedReceiver::close`] method is called.
///
/// [`UnboundedReceiver`]: crate::sync::mpsc::UnboundedReceiver
/// [`UnboundedReceiver::close`]: crate::sync::mpsc::UnboundedReceiver::close
///
/// ```
/// let (tx, rx) = tokio::sync::m... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 3ce4720a4532e40c78f7d851b1cfb8ea26542177 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3ce4720a4532e40c78f7d851b1cfb8ea26542177/tokio/src/sync/mpsc/unbounded.rs | 601 | 660 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:17 | /// the channel is closed.
#[must_use = "Downgrade creates a WeakSender without destroying the original non-weak sender."]
pub fn downgrade(&self) -> WeakUnboundedSender<T> {
WeakUnboundedSender {
chan: self.chan.downgrade(),
}
}
/// Returns the number of [`UnboundedSender`]... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 3ce4720a4532e40c78f7d851b1cfb8ea26542177 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3ce4720a4532e40c78f7d851b1cfb8ea26542177/tokio/src/sync/mpsc/unbounded.rs | 641 | 699 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:18 | chan::Tx::upgrade(self.chan.clone()).map(UnboundedSender::new)
}
/// Returns the number of [`UnboundedSender`] handles.
pub fn strong_count(&self) -> usize {
self.chan.strong_count()
}
/// Returns the number of [`WeakUnboundedSender`] handles.
pub fn weak_count(&self) -> usize {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 3ce4720a4532e40c78f7d851b1cfb8ea26542177 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3ce4720a4532e40c78f7d851b1cfb8ea26542177/tokio/src/sync/mpsc/unbounded.rs | 681 | 699 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:11 | /// Poll::Ready(count) => Poll::Ready(count),
/// }
/// }
/// }
///
/// #[tokio::main]
/// async fn main() {
/// let (tx, rx) = mpsc::unbounded_channel::<i32>();
/// let mut buffer = Vec::new();
///
/// let my_receiver_future = MyReceiverFuture... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 1846483f1953f6ac4dd89f434e78ff99eb0c92f9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1846483f1953f6ac4dd89f434e78ff99eb0c92f9/tokio/src/sync/mpsc/unbounded.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:12 | /// Attempts to send a message on this `UnboundedSender` without blocking.
///
/// This method is not marked async because sending a message to an unbounded channel
/// never requires any form of waiting. Because of this, the `send` method can be
/// used in both synchronous and asynchronous code withou... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 1846483f1953f6ac4dd89f434e78ff99eb0c92f9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1846483f1953f6ac4dd89f434e78ff99eb0c92f9/tokio/src/sync/mpsc/unbounded.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:13 | .semaphore()
.0
.compare_exchange(curr, curr + 2, AcqRel, Acquire)
{
Ok(_) => return true,
Err(actual) => {
curr = actual;
}
}
}
}
/// Completes when the receiver has dropped.
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 1846483f1953f6ac4dd89f434e78ff99eb0c92f9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1846483f1953f6ac4dd89f434e78ff99eb0c92f9/tokio/src/sync/mpsc/unbounded.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:14 | /// tx2.closed(),
/// tx3.closed(),
/// tx4.closed(),
/// tx5.closed()
/// );
//// println!("Receiver dropped");
/// }
/// ```
pub async fn closed(&self) {
self.chan.closed().await;
}
/// Checks if the channel has been closed. This... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 1846483f1953f6ac4dd89f434e78ff99eb0c92f9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1846483f1953f6ac4dd89f434e78ff99eb0c92f9/tokio/src/sync/mpsc/unbounded.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:15 | /// let tx2 = tx.clone();
/// assert!(tx.same_channel(&tx2));
///
/// let (tx3, rx3) = tokio::sync::mpsc::unbounded_channel::<()>();
/// assert!(!tx3.same_channel(&tx2));
/// ```
pub fn same_channel(&self, other: &Self) -> bool {
self.chan.same_channel(&other.chan)
}
/// Conver... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 1846483f1953f6ac4dd89f434e78ff99eb0c92f9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1846483f1953f6ac4dd89f434e78ff99eb0c92f9/tokio/src/sync/mpsc/unbounded.rs | 561 | 620 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:16 | }
impl<T> Drop for WeakUnboundedSender<T> {
fn drop(&mut self) {
self.chan.decrement_weak_count();
}
}
impl<T> WeakUnboundedSender<T> {
/// Tries to convert a `WeakUnboundedSender` into an [`UnboundedSender`].
/// This will return `Some` if there are other `Sender` instances alive and
/// ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 1846483f1953f6ac4dd89f434e78ff99eb0c92f9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1846483f1953f6ac4dd89f434e78ff99eb0c92f9/tokio/src/sync/mpsc/unbounded.rs | 601 | 632 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:15 | /// let tx2 = tx.clone();
/// assert!(tx.same_channel(&tx2));
///
/// let (tx3, rx3) = tokio::sync::mpsc::unbounded_channel::<()>();
/// assert!(!tx3.same_channel(&tx2));
/// ```
pub fn same_channel(&self, other: &Self) -> bool {
self.chan.same_channel(&other.chan)
}
/// Conver... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | fbdf539ac22563c6b8e3fb3f1844055baba12470 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fbdf539ac22563c6b8e3fb3f1844055baba12470/tokio/src/sync/mpsc/unbounded.rs | 561 | 604 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:14 | /// tx2.closed(),
/// tx3.closed(),
/// tx4.closed(),
/// tx5.closed()
/// );
//// println!("Receiver dropped");
/// }
/// ```
pub async fn closed(&self) {
self.chan.closed().await;
}
/// Checks if the channel has been closed. This... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 7341004535ffccc05ee8bd1fd856e587509335bf | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7341004535ffccc05ee8bd1fd856e587509335bf/tokio/src/sync/mpsc/unbounded.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:15 | /// let tx2 = tx.clone();
/// assert!(tx.same_channel(&tx2));
///
/// let (tx3, rx3) = tokio::sync::mpsc::unbounded_channel::<()>();
/// assert!(!tx3.same_channel(&tx2));
/// ```
pub fn same_channel(&self, other: &Self) -> bool {
self.chan.same_channel(&other.chan)
}
/// Conver... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 7341004535ffccc05ee8bd1fd856e587509335bf | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7341004535ffccc05ee8bd1fd856e587509335bf/tokio/src/sync/mpsc/unbounded.rs | 561 | 603 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:9 | /// Closes the receiving half of a channel, without dropping it.
///
/// This prevents any further messages from being sent on the channel while
/// still enabling the receiver to drain messages that are buffered.
///
/// To guarantee that no messages are dropped, after calling `close()`,
/// `r... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 58acb56a172747e5d9ddaec6bf578330d251ddaa | github | async-runtime | https://github.com/tokio-rs/tokio/blob/58acb56a172747e5d9ddaec6bf578330d251ddaa/tokio/src/sync/mpsc/unbounded.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:10 | UnboundedSender { chan }
}
/// Attempts to send a message on this `UnboundedSender` without blocking.
///
/// This method is not marked async because sending a message to an unbounded channel
/// never requires any form of waiting. Because of this, the `send` method can be
/// used in both sync... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 58acb56a172747e5d9ddaec6bf578330d251ddaa | github | async-runtime | https://github.com/tokio-rs/tokio/blob/58acb56a172747e5d9ddaec6bf578330d251ddaa/tokio/src/sync/mpsc/unbounded.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:11 | match self
.chan
.semaphore()
.0
.compare_exchange(curr, curr + 2, AcqRel, Acquire)
{
Ok(_) => return true,
Err(actual) => {
curr = actual;
}
}
}
}
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 58acb56a172747e5d9ddaec6bf578330d251ddaa | github | async-runtime | https://github.com/tokio-rs/tokio/blob/58acb56a172747e5d9ddaec6bf578330d251ddaa/tokio/src/sync/mpsc/unbounded.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:13 | ///
/// ```
/// let (tx, rx) = tokio::sync::mpsc::unbounded_channel::<()>();
/// let tx2 = tx.clone();
/// assert!(tx.same_channel(&tx2));
///
/// let (tx3, rx3) = tokio::sync::mpsc::unbounded_channel::<()>();
/// assert!(!tx3.same_channel(&tx2));
/// ```
pub fn same_channel(&self, ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 58acb56a172747e5d9ddaec6bf578330d251ddaa | github | async-runtime | https://github.com/tokio-rs/tokio/blob/58acb56a172747e5d9ddaec6bf578330d251ddaa/tokio/src/sync/mpsc/unbounded.rs | 481 | 526 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:1 | use crate::loom::sync::{atomic::AtomicUsize, Arc};
use crate::sync::mpsc::chan;
use crate::sync::mpsc::error::{SendError, TryRecvError};
use std::fmt;
use std::task::{Context, Poll};
/// Send values to the associated `UnboundedReceiver`.
///
/// Instances are created by the
/// [`unbounded_channel`](unbounded_channel... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 881b510a072f5acd773a10d3be0debf74113404e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/881b510a072f5acd773a10d3be0debf74113404e/tokio/src/sync/mpsc/unbounded.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:2 | /// // If we drop `tx`, then it will fail.
/// drop(tx);
/// assert!(tx_weak.clone().upgrade().is_none());
/// }
/// ```
pub struct WeakUnboundedSender<T> {
chan: Arc<chan::Chan<T, Semaphore>>,
}
impl<T> Clone for UnboundedSender<T> {
fn clone(&self) -> Self {
UnboundedSender {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 881b510a072f5acd773a10d3be0debf74113404e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/881b510a072f5acd773a10d3be0debf74113404e/tokio/src/sync/mpsc/unbounded.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:3 | fmt.debug_struct("UnboundedReceiver")
.field("chan", &self.chan)
.finish()
}
}
/// Creates an unbounded mpsc channel for communicating between asynchronous
/// tasks without backpressure.
///
/// A `send` on this channel will always succeed as long as the receive half has
/// not been close... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 881b510a072f5acd773a10d3be0debf74113404e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/881b510a072f5acd773a10d3be0debf74113404e/tokio/src/sync/mpsc/unbounded.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:9 | crate::future::block_on(self.recv())
}
/// Closes the receiving half of a channel, without dropping it.
///
/// This prevents any further messages from being sent on the channel while
/// still enabling the receiver to drain messages that are buffered.
///
/// To guarantee that no messages ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 881b510a072f5acd773a10d3be0debf74113404e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/881b510a072f5acd773a10d3be0debf74113404e/tokio/src/sync/mpsc/unbounded.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:10 | impl<T> UnboundedSender<T> {
pub(crate) fn new(chan: chan::Tx<T, Semaphore>) -> UnboundedSender<T> {
UnboundedSender { chan }
}
/// Attempts to send a message on this `UnboundedSender` without blocking.
///
/// This method is not marked async because sending a message to an unbounded channe... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 881b510a072f5acd773a10d3be0debf74113404e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/881b510a072f5acd773a10d3be0debf74113404e/tokio/src/sync/mpsc/unbounded.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:11 | process::abort()
}
match self
.chan
.semaphore()
.0
.compare_exchange(curr, curr + 2, AcqRel, Acquire)
{
Ok(_) => return true,
Err(actual) => {
curr = actual;
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 881b510a072f5acd773a10d3be0debf74113404e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/881b510a072f5acd773a10d3be0debf74113404e/tokio/src/sync/mpsc/unbounded.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:13 | ///
/// # Examples
///
/// ```
/// let (tx, rx) = tokio::sync::mpsc::unbounded_channel::<()>();
/// let tx2 = tx.clone();
/// assert!(tx.same_channel(&tx2));
///
/// let (tx3, rx3) = tokio::sync::mpsc::unbounded_channel::<()>();
/// assert!(!tx3.same_channel(&tx2));
/// ```
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 881b510a072f5acd773a10d3be0debf74113404e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/881b510a072f5acd773a10d3be0debf74113404e/tokio/src/sync/mpsc/unbounded.rs | 481 | 528 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:7 | /// sync_code.join().unwrap();
/// }
/// ```
#[track_caller]
#[cfg(feature = "sync")]
#[cfg_attr(docsrs, doc(alias = "recv_blocking"))]
pub fn blocking_recv(&mut self) -> Option<T> {
crate::future::block_on(self.recv())
}
/// Closes the receiving half of a channel, without d... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 6871084629ad95c37c7136d865890ab2e371ea12 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/sync/mpsc/unbounded.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:8 | /// guarantee that the next call will succeed — it could fail with another
/// spurious failure.
pub fn poll_recv(&mut self, cx: &mut Context<'_>) -> Poll<Option<T>> {
self.chan.recv(cx)
}
}
impl<T> UnboundedSender<T> {
pub(crate) fn new(chan: chan::Tx<T, Semaphore>) -> UnboundedSender<T> {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 6871084629ad95c37c7136d865890ab2e371ea12 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/sync/mpsc/unbounded.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:9 | if curr & 1 == 1 {
return false;
}
if curr == usize::MAX ^ 1 {
// Overflowed the ref count. There is no safe way to recover, so
// abort the process. In practice, this should never happen.
process::abort()
}
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 6871084629ad95c37c7136d865890ab2e371ea12 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/sync/mpsc/unbounded.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:11 | /// assert!(tx2.is_closed());
/// ```
pub fn is_closed(&self) -> bool {
self.chan.is_closed()
}
/// Returns `true` if senders belong to the same channel.
///
/// # Examples
///
/// ```
/// let (tx, rx) = tokio::sync::mpsc::unbounded_channel::<()>();
/// let tx2 = tx.clo... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 6871084629ad95c37c7136d865890ab2e371ea12 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/sync/mpsc/unbounded.rs | 401 | 455 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:12 | impl<T> WeakUnboundedSender<T> {
/// Tries to convert a `WeakUnboundedSender` into an [`UnboundedSender`].
/// This will return `Some` if there are other `Sender` instances alive and
/// the channel wasn't previously dropped, otherwise `None` is returned.
pub fn upgrade(&self) -> Option<UnboundedSender<... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 6871084629ad95c37c7136d865890ab2e371ea12 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/sync/mpsc/unbounded.rs | 441 | 455 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:1 | use crate::loom::sync::{atomic::AtomicUsize, Arc};
use crate::sync::mpsc::chan;
use crate::sync::mpsc::error::{SendError, TryRecvError};
use std::fmt;
use std::task::{Context, Poll};
/// Send values to the associated `UnboundedReceiver`.
///
/// Instances are created by the
/// [`unbounded_channel`](unbounded_channel... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | d19f2f2d395a4d6befb5f66ff87a19172aede2ee | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d19f2f2d395a4d6befb5f66ff87a19172aede2ee/tokio/src/sync/mpsc/unbounded.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:11 | /// assert!(tx2.is_closed());
/// ```
pub fn is_closed(&self) -> bool {
self.chan.is_closed()
}
/// Returns `true` if senders belong to the same channel.
///
/// # Examples
///
/// ```
/// let (tx, rx) = tokio::sync::mpsc::unbounded_channel::<()>();
/// let tx2 = tx.clo... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | d19f2f2d395a4d6befb5f66ff87a19172aede2ee | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d19f2f2d395a4d6befb5f66ff87a19172aede2ee/tokio/src/sync/mpsc/unbounded.rs | 401 | 455 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:12 | impl<T> WeakUnboundedSender<T> {
/// Tries to convert a WeakUnboundedSender into an [`UnboundedSender`].
/// This will return `Some` if there are other `Sender` instances alive and
/// the channel wasn't previously dropped, otherwise `None` is returned.
pub fn upgrade(&self) -> Option<UnboundedSender<T>... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | d19f2f2d395a4d6befb5f66ff87a19172aede2ee | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d19f2f2d395a4d6befb5f66ff87a19172aede2ee/tokio/src/sync/mpsc/unbounded.rs | 441 | 455 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:7 | /// sync_code.join().unwrap();
/// }
/// ```
#[track_caller]
#[cfg(feature = "sync")]
pub fn blocking_recv(&mut self) -> Option<T> {
crate::future::block_on(self.recv())
}
/// Closes the receiving half of a channel, without dropping it.
///
/// This prevents any further ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 582d51290772491aa01b2efbbc86d4bdc5fabe21 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/582d51290772491aa01b2efbbc86d4bdc5fabe21/tokio/src/sync/mpsc/unbounded.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:8 | /// spurious failure.
pub fn poll_recv(&mut self, cx: &mut Context<'_>) -> Poll<Option<T>> {
self.chan.recv(cx)
}
}
impl<T> UnboundedSender<T> {
pub(crate) fn new(chan: chan::Tx<T, Semaphore>) -> UnboundedSender<T> {
UnboundedSender { chan }
}
/// Attempts to send a message on this... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 582d51290772491aa01b2efbbc86d4bdc5fabe21 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/582d51290772491aa01b2efbbc86d4bdc5fabe21/tokio/src/sync/mpsc/unbounded.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:9 | return false;
}
if curr == usize::MAX ^ 1 {
// Overflowed the ref count. There is no safe way to recover, so
// abort the process. In practice, this should never happen.
process::abort()
}
match self
.chan
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 582d51290772491aa01b2efbbc86d4bdc5fabe21 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/582d51290772491aa01b2efbbc86d4bdc5fabe21/tokio/src/sync/mpsc/unbounded.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:11 | /// ```
pub fn is_closed(&self) -> bool {
self.chan.is_closed()
}
/// Returns `true` if senders belong to the same channel.
///
/// # Examples
///
/// ```
/// let (tx, rx) = tokio::sync::mpsc::unbounded_channel::<()>();
/// let tx2 = tx.clone();
/// assert!(tx.same_chan... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 582d51290772491aa01b2efbbc86d4bdc5fabe21 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/582d51290772491aa01b2efbbc86d4bdc5fabe21/tokio/src/sync/mpsc/unbounded.rs | 401 | 454 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:1 | use crate::loom::sync::atomic::AtomicUsize;
use crate::sync::mpsc::chan;
use crate::sync::mpsc::error::{SendError, TryRecvError};
use std::fmt;
use std::task::{Context, Poll};
/// Send values to the associated `UnboundedReceiver`.
///
/// Instances are created by the
/// [`unbounded_channel`](unbounded_channel) funct... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 15b362d2ddfc9eb51029b74d69dd74216a7a5b94 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/15b362d2ddfc9eb51029b74d69dd74216a7a5b94/tokio/src/sync/mpsc/unbounded.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:2 | /// The channel receiver
chan: chan::Rx<T, Semaphore>,
}
impl<T> fmt::Debug for UnboundedReceiver<T> {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_struct("UnboundedReceiver")
.field("chan", &self.chan)
.finish()
}
}
/// Creates an unbounded mpsc c... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 15b362d2ddfc9eb51029b74d69dd74216a7a5b94 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/15b362d2ddfc9eb51029b74d69dd74216a7a5b94/tokio/src/sync/mpsc/unbounded.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:6 | ///
/// let sync_code = thread::spawn(move || {
/// assert_eq!(Some(10), rx.blocking_recv());
/// });
///
/// let _ = tx.send(10);
/// sync_code.join().unwrap();
/// }
/// ```
#[track_caller]
#[cfg(feature = "sync")]
pub fn blocking_recv(&mut self) -> ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 15b362d2ddfc9eb51029b74d69dd74216a7a5b94 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/15b362d2ddfc9eb51029b74d69dd74216a7a5b94/tokio/src/sync/mpsc/unbounded.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:7 | /// recent call is scheduled to receive a wakeup.
///
/// If this method returns `Poll::Pending` due to a spurious failure, then
/// the `Waker` will be notified when the situation causing the spurious
/// failure has been resolved. Note that receiving such a wakeup does not
/// guarantee that the n... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 15b362d2ddfc9eb51029b74d69dd74216a7a5b94 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/15b362d2ddfc9eb51029b74d69dd74216a7a5b94/tokio/src/sync/mpsc/unbounded.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:8 | use std::sync::atomic::Ordering::{AcqRel, Acquire};
let mut curr = self.chan.semaphore().0.load(Acquire);
loop {
if curr & 1 == 1 {
return false;
}
if curr == usize::MAX ^ 1 {
// Overflowed the ref count. There is no safe way to reco... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 15b362d2ddfc9eb51029b74d69dd74216a7a5b94 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/15b362d2ddfc9eb51029b74d69dd74216a7a5b94/tokio/src/sync/mpsc/unbounded.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:10 | /// let tx2 = tx.clone();
/// assert!(!tx2.is_closed());
///
/// drop(rx);
/// assert!(tx.is_closed());
/// assert!(tx2.is_closed());
/// ```
pub fn is_closed(&self) -> bool {
self.chan.is_closed()
}
/// Returns `true` if senders belong to the same channel.
///
/// #... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 15b362d2ddfc9eb51029b74d69dd74216a7a5b94 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/15b362d2ddfc9eb51029b74d69dd74216a7a5b94/tokio/src/sync/mpsc/unbounded.rs | 361 | 387 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:2 | /// The channel receiver
chan: chan::Rx<T, Semaphore>,
}
impl<T> fmt::Debug for UnboundedReceiver<T> {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_struct("UnboundedReceiver")
.field("chan", &self.chan)
.finish()
}
}
/// Creates an unbounded mpsc c... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 4daeea8cad1ce8e67946bc0e17d499ab304b5ca2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4daeea8cad1ce8e67946bc0e17d499ab304b5ca2/tokio/src/sync/mpsc/unbounded.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:6 | /// let sync_code = thread::spawn(move || {
/// assert_eq!(Some(10), rx.blocking_recv());
/// });
///
/// let _ = tx.send(10);
/// sync_code.join().unwrap();
/// }
/// ```
#[track_caller]
#[cfg(feature = "sync")]
pub fn blocking_recv(&mut self) -> Option<T... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 4daeea8cad1ce8e67946bc0e17d499ab304b5ca2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4daeea8cad1ce8e67946bc0e17d499ab304b5ca2/tokio/src/sync/mpsc/unbounded.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:7 | ///
/// If this method returns `Poll::Pending` due to a spurious failure, then
/// the `Waker` will be notified when the situation causing the spurious
/// failure has been resolved. Note that receiving such a wakeup does not
/// guarantee that the next call will succeed — it could fail with another
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 4daeea8cad1ce8e67946bc0e17d499ab304b5ca2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4daeea8cad1ce8e67946bc0e17d499ab304b5ca2/tokio/src/sync/mpsc/unbounded.rs | 241 | 300 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.