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/chan.rs:6 | self.inner.semaphore.add_permit();
coop.made_progress();
return Ready(Some(value));
}
Some(Closed) => {
// TODO: This check may not be required as it most
// li... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | cf025ba45f68934ae2138bb75ee2a5ee50506d1b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cf025ba45f68934ae2138bb75ee2a5ee50506d1b/tokio/src/sync/mpsc/chan.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:7 | use super::block::Read::*;
self.inner.rx_fields.with_mut(|rx_fields_ptr| {
let rx_fields = unsafe { &mut *rx_fields_ptr };
match rx_fields.list.pop(&self.inner.tx) {
Some(Value(value)) => {
self.inner.semaphore.add_permit();
Ok(valu... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | cf025ba45f68934ae2138bb75ee2a5ee50506d1b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cf025ba45f68934ae2138bb75ee2a5ee50506d1b/tokio/src/sync/mpsc/chan.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:8 | }
}
impl<T, S> Drop for Chan<T, S> {
fn drop(&mut self) {
use super::block::Read::Value;
// Safety: the only owner of the rx fields is Chan, and eing
// inside its own Drop means we're the last ones to touch it.
self.rx_fields.with_mut(|rx_fields_ptr| {
let rx_fields = ... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | cf025ba45f68934ae2138bb75ee2a5ee50506d1b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cf025ba45f68934ae2138bb75ee2a5ee50506d1b/tokio/src/sync/mpsc/chan.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:9 | use std::sync::atomic::Ordering::{Acquire, Release};
use std::usize;
impl Semaphore for AtomicUsize {
fn add_permit(&self) {
let prev = self.fetch_sub(2, Release);
if prev >> 1 == 0 {
// Something went wrong
process::abort();
}
}
fn is_idle(&self) -> bool {... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | cf025ba45f68934ae2138bb75ee2a5ee50506d1b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cf025ba45f68934ae2138bb75ee2a5ee50506d1b/tokio/src/sync/mpsc/chan.rs | 321 | 345 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:1 | use crate::loom::cell::UnsafeCell;
use crate::loom::future::AtomicWaker;
use crate::loom::sync::atomic::AtomicUsize;
use crate::loom::sync::Arc;
use crate::sync::mpsc::error::{ClosedError, TryRecvError};
use crate::sync::mpsc::{error, list};
use std::fmt;
use std::process;
use std::sync::atomic::Ordering::{AcqRel, Rel... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 93f8cb8df2bb0dceb7921556165a8ed8efed9151 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/93f8cb8df2bb0dceb7921556165a8ed8efed9151/tokio/src/sync/mpsc/chan.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:2 | {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_struct("Rx").field("inner", &self.inner).finish()
}
}
#[derive(Debug, Eq, PartialEq)]
pub(crate) enum TrySendError {
Closed,
Full,
}
impl<T> From<(T, TrySendError)> for error::SendError<T> {
fn from(src: (T, TrySendEr... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 93f8cb8df2bb0dceb7921556165a8ed8efed9151 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/93f8cb8df2bb0dceb7921556165a8ed8efed9151/tokio/src/sync/mpsc/chan.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:3 | /// Returns true if the permit was acquired.
fn drop_permit(&self, permit: &mut Self::Permit) -> bool;
fn is_idle(&self) -> bool;
fn add_permit(&self);
fn poll_acquire(
&self,
cx: &mut Context<'_>,
permit: &mut Self::Permit,
) -> Poll<Result<(), ClosedError>>;
fn try_... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 93f8cb8df2bb0dceb7921556165a8ed8efed9151 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/93f8cb8df2bb0dceb7921556165a8ed8efed9151/tokio/src/sync/mpsc/chan.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:4 | rx_fields: UnsafeCell<RxFields<T>>,
}
impl<T, S> fmt::Debug for Chan<T, S>
where
S: fmt::Debug,
{
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_struct("Chan")
.field("tx", &self.tx)
.field("semaphore", &self.semaphore)
.field("rx_waker", &sel... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 93f8cb8df2bb0dceb7921556165a8ed8efed9151 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/93f8cb8df2bb0dceb7921556165a8ed8efed9151/tokio/src/sync/mpsc/chan.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:5 | where
S: Semaphore,
{
let (tx, rx) = list::channel();
let chan = Arc::new(Chan {
tx,
semaphore,
rx_waker: AtomicWaker::new(),
tx_count: AtomicUsize::new(1),
rx_fields: UnsafeCell::new(RxFields {
list: rx,
rx_closed: false,
}),
});
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 93f8cb8df2bb0dceb7921556165a8ed8efed9151 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/93f8cb8df2bb0dceb7921556165a8ed8efed9151/tokio/src/sync/mpsc/chan.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:6 | /// Send a message and notify the receiver.
pub(crate) fn try_send(&mut self, value: T) -> Result<(), (T, TrySendError)> {
self.inner.try_send(value, &mut self.permit)
}
}
impl<T> Tx<T, (crate::sync::semaphore_ll::Semaphore, usize)> {
pub(crate) fn is_ready(&self) -> bool {
self.permit.is_a... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 93f8cb8df2bb0dceb7921556165a8ed8efed9151 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/93f8cb8df2bb0dceb7921556165a8ed8efed9151/tokio/src/sync/mpsc/chan.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:7 | let notify = self.inner.semaphore.drop_permit(&mut self.permit);
if notify && self.inner.semaphore.is_idle() {
self.inner.rx_waker.wake();
}
if self.inner.tx_count.fetch_sub(1, AcqRel) != 1 {
return;
}
// Close the list, which sends a `Close` message
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 93f8cb8df2bb0dceb7921556165a8ed8efed9151 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/93f8cb8df2bb0dceb7921556165a8ed8efed9151/tokio/src/sync/mpsc/chan.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:8 | }
/// Receive the next value
pub(crate) fn recv(&mut self, cx: &mut Context<'_>) -> Poll<Option<T>> {
use super::block::Read::*;
// Keep track of task budget
let coop = ready!(crate::coop::poll_proceed(cx));
self.inner.rx_fields.with_mut(|rx_fields_ptr| {
let rx_fi... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 93f8cb8df2bb0dceb7921556165a8ed8efed9151 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/93f8cb8df2bb0dceb7921556165a8ed8efed9151/tokio/src/sync/mpsc/chan.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:9 | // It is possible that a value was pushed between attempting to read
// and registering the task, so we have to check the channel a
// second time here.
try_recv!();
if rx_fields.rx_closed && self.inner.semaphore.is_idle() {
coop.made_progress();
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 93f8cb8df2bb0dceb7921556165a8ed8efed9151 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/93f8cb8df2bb0dceb7921556165a8ed8efed9151/tokio/src/sync/mpsc/chan.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:10 | self.inner.rx_fields.with_mut(|rx_fields_ptr| {
let rx_fields = unsafe { &mut *rx_fields_ptr };
while let Some(Value(_)) = rx_fields.list.pop(&self.inner.tx) {
self.inner.semaphore.add_permit();
}
})
}
}
// ===== impl Chan =====
impl<T, S> Chan<T, S>
wh... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 93f8cb8df2bb0dceb7921556165a8ed8efed9151 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/93f8cb8df2bb0dceb7921556165a8ed8efed9151/tokio/src/sync/mpsc/chan.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:11 | self.rx_fields.with_mut(|rx_fields_ptr| {
let rx_fields = unsafe { &mut *rx_fields_ptr };
while let Some(Value(_)) = rx_fields.list.pop(&self.tx) {}
unsafe { rx_fields.list.free_blocks() };
});
}
}
use crate::sync::semaphore_ll::TryAcquireError;
impl From<TryAcquireErr... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 93f8cb8df2bb0dceb7921556165a8ed8efed9151 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/93f8cb8df2bb0dceb7921556165a8ed8efed9151/tokio/src/sync/mpsc/chan.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:12 | fn add_permit(&self) {
self.0.add_permits(1)
}
fn is_idle(&self) -> bool {
self.0.available_permits() == self.1
}
fn poll_acquire(
&self,
cx: &mut Context<'_>,
permit: &mut Permit,
) -> Poll<Result<(), ClosedError>> {
// Keep track of task budget
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 93f8cb8df2bb0dceb7921556165a8ed8efed9151 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/93f8cb8df2bb0dceb7921556165a8ed8efed9151/tokio/src/sync/mpsc/chan.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:13 | use std::sync::atomic::Ordering::{Acquire, Release};
use std::usize;
impl Semaphore for AtomicUsize {
type Permit = ();
fn new_permit() {}
fn drop_permit(&self, _permit: &mut ()) -> bool {
false
}
fn add_permit(&self) {
let prev = self.fetch_sub(2, Release);
if prev >> 1... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 93f8cb8df2bb0dceb7921556165a8ed8efed9151 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/93f8cb8df2bb0dceb7921556165a8ed8efed9151/tokio/src/sync/mpsc/chan.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:14 | }
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.compare_exchange(curr, curr + 2, AcqRel, Acquire... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 93f8cb8df2bb0dceb7921556165a8ed8efed9151 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/93f8cb8df2bb0dceb7921556165a8ed8efed9151/tokio/src/sync/mpsc/chan.rs | 521 | 543 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:2 | {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_struct("Rx").field("inner", &self.inner).finish()
}
}
#[derive(Debug, Eq, PartialEq)]
pub(crate) enum TrySendError {
Closed,
Full,
}
impl<T> From<(T, TrySendError)> for error::SendError<T> {
fn from(src: (T, TrySendEr... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 9f63911adc5b809fd3df7cfbb736897a86895e0c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9f63911adc5b809fd3df7cfbb736897a86895e0c/tokio/src/sync/mpsc/chan.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:3 | fn add_permit(&self);
fn poll_acquire(
&self,
cx: &mut Context<'_>,
permit: &mut Self::Permit,
) -> Poll<Result<(), ClosedError>>;
fn try_acquire(&self, permit: &mut Self::Permit) -> Result<(), TrySendError>;
/// A value was sent into the channel and the permit held by `tx` is... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 9f63911adc5b809fd3df7cfbb736897a86895e0c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9f63911adc5b809fd3df7cfbb736897a86895e0c/tokio/src/sync/mpsc/chan.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:4 | where
S: fmt::Debug,
{
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_struct("Chan")
.field("tx", &self.tx)
.field("semaphore", &self.semaphore)
.field("rx_waker", &self.rx_waker)
.field("tx_count", &self.tx_count)
.fiel... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 9f63911adc5b809fd3df7cfbb736897a86895e0c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9f63911adc5b809fd3df7cfbb736897a86895e0c/tokio/src/sync/mpsc/chan.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:5 | let chan = Arc::new(Chan {
tx,
semaphore,
rx_waker: AtomicWaker::new(),
tx_count: AtomicUsize::new(1),
rx_fields: UnsafeCell::new(RxFields {
list: rx,
rx_closed: false,
}),
});
(Tx::new(chan.clone()), Rx::new(chan))
}
// ===== impl Tx ===... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 9f63911adc5b809fd3df7cfbb736897a86895e0c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9f63911adc5b809fd3df7cfbb736897a86895e0c/tokio/src/sync/mpsc/chan.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:6 | }
}
impl<T> Tx<T, (crate::sync::semaphore_ll::Semaphore, usize)> {
pub(crate) fn is_ready(&self) -> bool {
self.permit.is_acquired()
}
}
impl<T> Tx<T, AtomicUsize> {
pub(crate) fn send_unbounded(&self, value: T) -> Result<(), (T, TrySendError)> {
self.inner.try_send(value, &mut ())
}
}... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 9f63911adc5b809fd3df7cfbb736897a86895e0c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9f63911adc5b809fd3df7cfbb736897a86895e0c/tokio/src/sync/mpsc/chan.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:7 | }
// Close the list, which sends a `Close` message
self.inner.tx.close();
// Notify the receiver
self.inner.rx_waker.wake();
}
}
// ===== impl Rx =====
impl<T, S> Rx<T, S>
where
S: Semaphore,
{
fn new(chan: Arc<Chan<T, S>>) -> Rx<T, S> {
Rx { inner: chan }
}
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 9f63911adc5b809fd3df7cfbb736897a86895e0c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9f63911adc5b809fd3df7cfbb736897a86895e0c/tokio/src/sync/mpsc/chan.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:8 | self.inner.rx_fields.with_mut(|rx_fields_ptr| {
let rx_fields = unsafe { &mut *rx_fields_ptr };
macro_rules! try_recv {
() => {
match rx_fields.list.pop(&self.inner.tx) {
Some(Value(value)) => {
self.inner.s... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 9f63911adc5b809fd3df7cfbb736897a86895e0c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9f63911adc5b809fd3df7cfbb736897a86895e0c/tokio/src/sync/mpsc/chan.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:9 | } else {
Pending
}
})
}
/// Receives the next value without blocking
pub(crate) fn try_recv(&mut self) -> Result<T, TryRecvError> {
use super::block::Read::*;
self.inner.rx_fields.with_mut(|rx_fields_ptr| {
let rx_fields = unsafe { &mut *rx_fi... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 9f63911adc5b809fd3df7cfbb736897a86895e0c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9f63911adc5b809fd3df7cfbb736897a86895e0c/tokio/src/sync/mpsc/chan.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:10 | }
// ===== impl Chan =====
impl<T, S> Chan<T, S>
where
S: Semaphore,
{
fn try_send(&self, value: T, permit: &mut S::Permit) -> Result<(), (T, TrySendError)> {
if let Err(e) = self.semaphore.try_acquire(permit) {
return Err((value, e));
}
// Push the value
self.tx.p... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 9f63911adc5b809fd3df7cfbb736897a86895e0c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9f63911adc5b809fd3df7cfbb736897a86895e0c/tokio/src/sync/mpsc/chan.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:11 | use crate::sync::semaphore_ll::TryAcquireError;
impl From<TryAcquireError> for TrySendError {
fn from(src: TryAcquireError) -> TrySendError {
if src.is_closed() {
TrySendError::Closed
} else if src.is_no_permits() {
TrySendError::Full
} else {
unreachable... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 9f63911adc5b809fd3df7cfbb736897a86895e0c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9f63911adc5b809fd3df7cfbb736897a86895e0c/tokio/src/sync/mpsc/chan.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:12 | cx: &mut Context<'_>,
permit: &mut Permit,
) -> Poll<Result<(), ClosedError>> {
// Keep track of task budget
let coop = ready!(crate::coop::poll_proceed(cx));
permit
.poll_acquire(cx, 1, &self.0)
.map_err(|_| ClosedError::new())
.map(move |r| {
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 9f63911adc5b809fd3df7cfbb736897a86895e0c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9f63911adc5b809fd3df7cfbb736897a86895e0c/tokio/src/sync/mpsc/chan.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:13 | fn add_permit(&self) {
let prev = self.fetch_sub(2, Release);
if prev >> 1 == 0 {
// Something went wrong
process::abort();
}
}
fn is_idle(&self) -> bool {
self.load(Acquire) >> 1 == 0
}
fn poll_acquire(
&self,
_cx: &mut Context<... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 9f63911adc5b809fd3df7cfbb736897a86895e0c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9f63911adc5b809fd3df7cfbb736897a86895e0c/tokio/src/sync/mpsc/chan.rs | 481 | 531 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:14 | }
}
}
}
fn forget(&self, _permit: &mut ()) {}
fn close(&self) {
self.fetch_or(1, Release);
}
} | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 9f63911adc5b809fd3df7cfbb736897a86895e0c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9f63911adc5b809fd3df7cfbb736897a86895e0c/tokio/src/sync/mpsc/chan.rs | 521 | 531 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:7 | }
// Close the list, which sends a `Close` message
self.inner.tx.close();
// Notify the receiver
self.inner.rx_waker.wake();
}
}
// ===== impl Rx =====
impl<T, S> Rx<T, S>
where
S: Semaphore,
{
fn new(chan: Arc<Chan<T, S>>) -> Rx<T, S> {
Rx { inner: chan }
}
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 7fb1698e8d8fa9d4ce295b63a17c461b3a40dddd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7fb1698e8d8fa9d4ce295b63a17c461b3a40dddd/tokio/src/sync/mpsc/chan.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:8 | self.inner.rx_fields.with_mut(|rx_fields_ptr| {
let rx_fields = unsafe { &mut *rx_fields_ptr };
macro_rules! try_recv {
() => {
match rx_fields.list.pop(&self.inner.tx) {
Some(Value(value)) => {
self.inner.s... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 7fb1698e8d8fa9d4ce295b63a17c461b3a40dddd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7fb1698e8d8fa9d4ce295b63a17c461b3a40dddd/tokio/src/sync/mpsc/chan.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:9 | })
}
/// Receives the next value without blocking
pub(crate) fn try_recv(&mut self) -> Result<T, TryRecvError> {
use super::block::Read::*;
self.inner.rx_fields.with_mut(|rx_fields_ptr| {
let rx_fields = unsafe { &mut *rx_fields_ptr };
match rx_fields.list.pop(&self.... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 7fb1698e8d8fa9d4ce295b63a17c461b3a40dddd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7fb1698e8d8fa9d4ce295b63a17c461b3a40dddd/tokio/src/sync/mpsc/chan.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:10 | impl<T, S> Chan<T, S>
where
S: Semaphore,
{
fn try_send(&self, value: T, permit: &mut S::Permit) -> Result<(), (T, TrySendError)> {
if let Err(e) = self.semaphore.try_acquire(permit) {
return Err((value, e));
}
// Push the value
self.tx.push(value);
// Notif... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 7fb1698e8d8fa9d4ce295b63a17c461b3a40dddd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7fb1698e8d8fa9d4ce295b63a17c461b3a40dddd/tokio/src/sync/mpsc/chan.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:11 | impl From<TryAcquireError> for TrySendError {
fn from(src: TryAcquireError) -> TrySendError {
if src.is_closed() {
TrySendError::Closed
} else if src.is_no_permits() {
TrySendError::Full
} else {
unreachable!();
}
}
}
// ===== impl Semaphore f... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 7fb1698e8d8fa9d4ce295b63a17c461b3a40dddd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7fb1698e8d8fa9d4ce295b63a17c461b3a40dddd/tokio/src/sync/mpsc/chan.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:12 | // Keep track of task budget
ready!(crate::coop::poll_proceed(cx));
permit
.poll_acquire(cx, 1, &self.0)
.map_err(|_| ClosedError::new())
}
fn try_acquire(&self, permit: &mut Permit) -> Result<(), TrySendError> {
permit.try_acquire(1, &self.0)?;
Ok(())
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 7fb1698e8d8fa9d4ce295b63a17c461b3a40dddd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7fb1698e8d8fa9d4ce295b63a17c461b3a40dddd/tokio/src/sync/mpsc/chan.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:13 | }
}
fn is_idle(&self) -> bool {
self.load(Acquire) >> 1 == 0
}
fn poll_acquire(
&self,
_cx: &mut Context<'_>,
permit: &mut (),
) -> Poll<Result<(), ClosedError>> {
Ready(self.try_acquire(permit).map_err(|_| ClosedError::new()))
}
fn try_acquire(&sel... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 7fb1698e8d8fa9d4ce295b63a17c461b3a40dddd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7fb1698e8d8fa9d4ce295b63a17c461b3a40dddd/tokio/src/sync/mpsc/chan.rs | 481 | 524 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:5 | let chan = Arc::new(Chan {
tx,
semaphore,
rx_waker: AtomicWaker::new(),
tx_count: AtomicUsize::new(1),
rx_fields: UnsafeCell::new(RxFields {
list: rx,
rx_closed: false,
}),
});
(Tx::new(chan.clone()), Rx::new(chan))
}
// ===== impl Tx ===... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 1cb1e291c10adf6b4e530cb1475b95ba10fa615f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1cb1e291c10adf6b4e530cb1475b95ba10fa615f/tokio/src/sync/mpsc/chan.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:6 | self.inner.try_send(value, &mut ())
}
}
impl<T, S> Clone for Tx<T, S>
where
S: Semaphore,
{
fn clone(&self) -> Tx<T, S> {
// Using a Relaxed ordering here is sufficient as the caller holds a
// strong ref to `self`, preventing a concurrent decrement to zero.
self.inner.tx_count.fetc... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 1cb1e291c10adf6b4e530cb1475b95ba10fa615f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1cb1e291c10adf6b4e530cb1475b95ba10fa615f/tokio/src/sync/mpsc/chan.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:7 | impl<T, S> Rx<T, S>
where
S: Semaphore,
{
fn new(chan: Arc<Chan<T, S>>) -> Rx<T, S> {
Rx { inner: chan }
}
pub(crate) fn close(&mut self) {
self.inner.rx_fields.with_mut(|rx_fields_ptr| {
let rx_fields = unsafe { &mut *rx_fields_ptr };
if rx_fields.rx_closed {
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 1cb1e291c10adf6b4e530cb1475b95ba10fa615f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1cb1e291c10adf6b4e530cb1475b95ba10fa615f/tokio/src/sync/mpsc/chan.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:8 | Some(Closed) => {
// TODO: This check may not be required as it most
// likely can only return `true` at this point. A
// channel is closed when all tx handles are
// dropped. Dropping a tx handle releases me... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 1cb1e291c10adf6b4e530cb1475b95ba10fa615f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1cb1e291c10adf6b4e530cb1475b95ba10fa615f/tokio/src/sync/mpsc/chan.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:9 | Ok(value)
}
Some(Closed) => Err(TryRecvError::Closed),
None => Err(TryRecvError::Empty),
}
})
}
}
impl<T, S> Drop for Rx<T, S>
where
S: Semaphore,
{
fn drop(&mut self) {
use super::block::Read::Value;
self.close();
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 1cb1e291c10adf6b4e530cb1475b95ba10fa615f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1cb1e291c10adf6b4e530cb1475b95ba10fa615f/tokio/src/sync/mpsc/chan.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:10 | self.tx.push(value);
// Notify the rx task
self.rx_waker.wake();
// Release the permit
self.semaphore.forget(permit);
Ok(())
}
}
impl<T, S> Drop for Chan<T, S> {
fn drop(&mut self) {
use super::block::Read::Value;
// Safety: the only owner of the rx f... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 1cb1e291c10adf6b4e530cb1475b95ba10fa615f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1cb1e291c10adf6b4e530cb1475b95ba10fa615f/tokio/src/sync/mpsc/chan.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:11 | // ===== impl Semaphore for (::Semaphore, capacity) =====
use crate::sync::semaphore_ll::Permit;
impl Semaphore for (crate::sync::semaphore_ll::Semaphore, usize) {
type Permit = Permit;
fn new_permit() -> Permit {
Permit::new()
}
fn drop_permit(&self, permit: &mut Permit) {
permit.re... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 1cb1e291c10adf6b4e530cb1475b95ba10fa615f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1cb1e291c10adf6b4e530cb1475b95ba10fa615f/tokio/src/sync/mpsc/chan.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:12 | }
fn forget(&self, permit: &mut Self::Permit) {
permit.forget(1);
}
fn close(&self) {
self.0.close();
}
}
// ===== impl Semaphore for AtomicUsize =====
use std::sync::atomic::Ordering::{Acquire, Release};
use std::usize;
impl Semaphore for AtomicUsize {
type Permit = ();
fn... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 1cb1e291c10adf6b4e530cb1475b95ba10fa615f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1cb1e291c10adf6b4e530cb1475b95ba10fa615f/tokio/src/sync/mpsc/chan.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:13 | ) -> Poll<Result<(), ClosedError>> {
Ready(self.try_acquire(permit).map_err(|_| ClosedError::new()))
}
fn try_acquire(&self, _permit: &mut ()) -> Result<(), TrySendError> {
let mut curr = self.load(Acquire);
loop {
if curr & 1 == 1 {
return Err(TrySendError:... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 1cb1e291c10adf6b4e530cb1475b95ba10fa615f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1cb1e291c10adf6b4e530cb1475b95ba10fa615f/tokio/src/sync/mpsc/chan.rs | 481 | 513 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:1 | use crate::loom::cell::CausalCell;
use crate::loom::future::AtomicWaker;
use crate::loom::sync::atomic::AtomicUsize;
use crate::loom::sync::Arc;
use crate::sync::mpsc::error::{ClosedError, TryRecvError};
use crate::sync::mpsc::{error, list};
use std::fmt;
use std::process;
use std::sync::atomic::Ordering::{AcqRel, Rel... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 06a4d895ec8787386058a24b422dfa9a8514bc8e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/06a4d895ec8787386058a24b422dfa9a8514bc8e/tokio/src/sync/mpsc/chan.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:3 | fn add_permit(&self);
fn poll_acquire(
&self,
cx: &mut Context<'_>,
permit: &mut Self::Permit,
) -> Poll<Result<(), ClosedError>>;
fn try_acquire(&self, permit: &mut Self::Permit) -> Result<(), TrySendError>;
/// A value was sent into the channel and the permit held by `tx` is... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 06a4d895ec8787386058a24b422dfa9a8514bc8e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/06a4d895ec8787386058a24b422dfa9a8514bc8e/tokio/src/sync/mpsc/chan.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:4 | where
S: fmt::Debug,
{
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_struct("Chan")
.field("tx", &self.tx)
.field("semaphore", &self.semaphore)
.field("rx_waker", &self.rx_waker)
.field("tx_count", &self.tx_count)
.fiel... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 06a4d895ec8787386058a24b422dfa9a8514bc8e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/06a4d895ec8787386058a24b422dfa9a8514bc8e/tokio/src/sync/mpsc/chan.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:5 | let chan = Arc::new(Chan {
tx,
semaphore,
rx_waker: AtomicWaker::new(),
tx_count: AtomicUsize::new(1),
rx_fields: CausalCell::new(RxFields {
list: rx,
rx_closed: false,
}),
});
(Tx::new(chan.clone()), Rx::new(chan))
}
// ===== impl Tx ===... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 06a4d895ec8787386058a24b422dfa9a8514bc8e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/06a4d895ec8787386058a24b422dfa9a8514bc8e/tokio/src/sync/mpsc/chan.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:7 | impl<T, S> Rx<T, S>
where
S: Semaphore,
{
fn new(chan: Arc<Chan<T, S>>) -> Rx<T, S> {
Rx { inner: chan }
}
pub(crate) fn close(&mut self) {
self.inner.rx_fields.with_mut(|rx_fields_ptr| {
let rx_fields = unsafe { &mut *rx_fields_ptr };
if rx_fields.rx_closed {
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | f9ddb93604a830d106475bd4c4cae436fafcc0da | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/sync/mpsc/chan.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:8 | // channel is closed when all tx handles are
// dropped. Dropping a tx handle releases memory,
// which ensures that if dropping the tx handle is
// visible, then all messages sent are also visible.
assert!(s... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | f9ddb93604a830d106475bd4c4cae436fafcc0da | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/sync/mpsc/chan.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:9 | None => Err(TryRecvError::Empty),
}
})
}
}
impl<T, S> Drop for Rx<T, S>
where
S: Semaphore,
{
fn drop(&mut self) {
use super::block::Read::Value;
self.close();
self.inner.rx_fields.with_mut(|rx_fields_ptr| {
let rx_fields = unsafe { &mut *rx_fields_... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | f9ddb93604a830d106475bd4c4cae436fafcc0da | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/sync/mpsc/chan.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:10 | self.rx_waker.wake();
// Release the permit
self.semaphore.forget(permit);
Ok(())
}
}
impl<T, S> Drop for Chan<T, S> {
fn drop(&mut self) {
use super::block::Read::Value;
// Safety: the only owner of the rx fields is Chan, and eing
// inside its own Drop means... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | f9ddb93604a830d106475bd4c4cae436fafcc0da | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/sync/mpsc/chan.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:11 | use crate::sync::semaphore_ll::Permit;
impl Semaphore for (crate::sync::semaphore_ll::Semaphore, usize) {
type Permit = Permit;
fn new_permit() -> Permit {
Permit::new()
}
fn drop_permit(&self, permit: &mut Permit) {
permit.release(1, &self.0);
}
fn add_permit(&self) {
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | f9ddb93604a830d106475bd4c4cae436fafcc0da | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/sync/mpsc/chan.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:12 | fn close(&self) {
self.0.close();
}
}
// ===== impl Semaphore for AtomicUsize =====
use std::sync::atomic::Ordering::{Acquire, Release};
use std::usize;
impl Semaphore for AtomicUsize {
type Permit = ();
fn new_permit() {}
fn drop_permit(&self, _permit: &mut ()) {}
fn add_permit(&self)... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | f9ddb93604a830d106475bd4c4cae436fafcc0da | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/sync/mpsc/chan.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:13 | loop {
if curr & 1 == 1 {
return Err(TrySendError::Closed);
}
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.
pro... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | f9ddb93604a830d106475bd4c4cae436fafcc0da | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/sync/mpsc/chan.rs | 481 | 507 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:8 | // channel is closed when all tx handles are
// dropped. Dropping a tx handle releases memory,
// which ensures that if dropping the tx handle is
// visible, then all messages sent are also visible.
assert!(s... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | efcbf9613f2d5048550f9c828e3be422644f1391 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/efcbf9613f2d5048550f9c828e3be422644f1391/tokio/src/sync/mpsc/chan.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:10 | self.rx_waker.wake();
// Release the permit
self.semaphore.forget(permit);
Ok(())
}
}
impl<T, S> Drop for Chan<T, S> {
fn drop(&mut self) {
use super::block::Read::Value;
// Safety: the only owner of the rx fields is Chan, and eing
// inside its own Drop means... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 9211adbe01661585cd1831214279262024d04816 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9211adbe01661585cd1831214279262024d04816/tokio/src/sync/mpsc/chan.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:11 | use crate::sync::semaphore_ll::Permit;
impl Semaphore for (crate::sync::semaphore_ll::Semaphore, usize) {
type Permit = Permit;
fn new_permit() -> Permit {
Permit::new()
}
fn drop_permit(&self, permit: &mut Permit) {
permit.release(&self.0);
}
fn add_permit(&self) {
s... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 9211adbe01661585cd1831214279262024d04816 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9211adbe01661585cd1831214279262024d04816/tokio/src/sync/mpsc/chan.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:10 | self.rx_waker.wake();
// Release the permit
self.semaphore.forget(permit);
Ok(())
}
}
impl<T, S> Drop for Chan<T, S> {
fn drop(&mut self) {
use super::block::Read::Value;
// Safety: the only owner of the rx fields is Chan, and eing
// inside its own Drop means... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 975576952f33c64e4faaa616f67ae9d6b596e4aa | github | async-runtime | https://github.com/tokio-rs/tokio/blob/975576952f33c64e4faaa616f67ae9d6b596e4aa/tokio/src/sync/mpsc/chan.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:11 | use crate::sync::semaphore::Permit;
impl Semaphore for (crate::sync::semaphore::Semaphore, usize) {
type Permit = Permit;
fn new_permit() -> Permit {
Permit::new()
}
fn drop_permit(&self, permit: &mut Permit) {
permit.release(&self.0);
}
fn add_permit(&self) {
self.0.... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 975576952f33c64e4faaa616f67ae9d6b596e4aa | github | async-runtime | https://github.com/tokio-rs/tokio/blob/975576952f33c64e4faaa616f67ae9d6b596e4aa/tokio/src/sync/mpsc/chan.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:1 | use crate::loom::cell::CausalCell;
use crate::loom::future::AtomicWaker;
use crate::loom::sync::atomic::AtomicUsize;
use crate::loom::sync::Arc;
use crate::sync::mpsc::error::ClosedError;
use crate::sync::mpsc::{error, list};
use std::fmt;
use std::process;
use std::sync::atomic::Ordering::{AcqRel, Relaxed};
use std::... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 942feab040e28d1e1547012a0fb81212299e6596 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/942feab040e28d1e1547012a0fb81212299e6596/tokio/src/sync/mpsc/chan.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:8 | // channel is closed when all tx handles are
// dropped. Dropping a tx handle releases memory,
// which ensures that if dropping the tx handle is
// visible, then all messages sent are also visible.
assert!(s... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 942feab040e28d1e1547012a0fb81212299e6596 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/942feab040e28d1e1547012a0fb81212299e6596/tokio/src/sync/mpsc/chan.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:9 | let rx_fields = unsafe { &mut *rx_fields_ptr };
while let Some(Value(_)) = rx_fields.list.pop(&self.inner.tx) {
self.inner.semaphore.add_permit();
}
})
}
}
// ===== impl Chan =====
impl<T, S> Chan<T, S>
where
S: Semaphore,
{
fn try_send(&self, value: T, per... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 942feab040e28d1e1547012a0fb81212299e6596 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/942feab040e28d1e1547012a0fb81212299e6596/tokio/src/sync/mpsc/chan.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:10 | let rx_fields = unsafe { &mut *rx_fields_ptr };
while let Some(Value(_)) = rx_fields.list.pop(&self.tx) {}
unsafe { rx_fields.list.free_blocks() };
});
}
}
use crate::sync::semaphore::TryAcquireError;
impl From<TryAcquireError> for TrySendError {
fn from(src: TryAcquireError) ... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 942feab040e28d1e1547012a0fb81212299e6596 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/942feab040e28d1e1547012a0fb81212299e6596/tokio/src/sync/mpsc/chan.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:11 | fn is_idle(&self) -> bool {
self.0.available_permits() == self.1
}
fn poll_acquire(
&self,
cx: &mut Context<'_>,
permit: &mut Permit,
) -> Poll<Result<(), ClosedError>> {
permit
.poll_acquire(cx, &self.0)
.map_err(|_| ClosedError::new())
}... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 942feab040e28d1e1547012a0fb81212299e6596 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/942feab040e28d1e1547012a0fb81212299e6596/tokio/src/sync/mpsc/chan.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:7 | impl<T, S> Rx<T, S>
where
S: Semaphore,
{
fn new(chan: Arc<Chan<T, S>>) -> Rx<T, S> {
Rx { inner: chan }
}
pub(crate) fn close(&mut self) {
self.inner.rx_fields.with_mut(|rx_fields_ptr| {
let rx_fields = unsafe { &mut *rx_fields_ptr };
if rx_fields.rx_closed {
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 0d38936b35779b604770120da2e98560bbb6241f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0d38936b35779b604770120da2e98560bbb6241f/tokio/src/sync/mpsc/chan.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:8 | // channel is closed when all tx handles are
// dropped. Dropping a tx handle releases memory,
// which ensures that if dropping the tx handle is
// visible, then all messages sent are also visible.
assert!(... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 0d38936b35779b604770120da2e98560bbb6241f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0d38936b35779b604770120da2e98560bbb6241f/tokio/src/sync/mpsc/chan.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:8 | // channel is closed when all tx handles are
// dropped. Dropping a tx handle releases memory,
// which ensures that if dropping the tx handle is
// visible, then all messages sent are also visible.
assert!(... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 8a7e57786a5dca139f5b4261685e22991ded0859 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8a7e57786a5dca139f5b4261685e22991ded0859/tokio/src/sync/mpsc/chan.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:9 | fn drop(&mut self) {
use super::block::Read::Value;
self.close();
self.inner.rx_fields.with_mut(|rx_fields_ptr| {
let rx_fields = unsafe { &mut *rx_fields_ptr };
while let Some(Value(_)) = rx_fields.list.pop(&self.inner.tx) {
self.inner.semaphore.add_pe... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 8a7e57786a5dca139f5b4261685e22991ded0859 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8a7e57786a5dca139f5b4261685e22991ded0859/tokio/src/sync/mpsc/chan.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:10 | fn drop(&mut self) {
use super::block::Read::Value;
// Safety: the only owner of the rx fields is Chan, and eing
// inside its own Drop means we're the last ones to touch it.
self.rx_fields.with_mut(|rx_fields_ptr| {
let rx_fields = unsafe { &mut *rx_fields_ptr };
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 8a7e57786a5dca139f5b4261685e22991ded0859 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8a7e57786a5dca139f5b4261685e22991ded0859/tokio/src/sync/mpsc/chan.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:11 | permit.release(&self.0);
}
fn add_permit(&self) {
self.0.add_permits(1)
}
fn is_idle(&self) -> bool {
self.0.available_permits() == self.1
}
fn poll_acquire(
&self,
cx: &mut Context<'_>,
permit: &mut Permit,
) -> Poll<Result<(), ClosedError>> {
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 8a7e57786a5dca139f5b4261685e22991ded0859 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8a7e57786a5dca139f5b4261685e22991ded0859/tokio/src/sync/mpsc/chan.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:12 | impl Semaphore for AtomicUsize {
type Permit = ();
fn new_permit() {}
fn drop_permit(&self, _permit: &mut ()) {}
fn add_permit(&self) {
let prev = self.fetch_sub(2, Release);
if prev >> 1 == 0 {
// Something went wrong
process::abort();
}
}
fn... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 8a7e57786a5dca139f5b4261685e22991ded0859 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8a7e57786a5dca139f5b4261685e22991ded0859/tokio/src/sync/mpsc/chan.rs | 441 | 497 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:13 | }
match self.compare_exchange(curr, curr + 2, AcqRel, Acquire) {
Ok(_) => return Ok(()),
Err(actual) => {
curr = actual;
}
}
}
}
fn forget(&self, _permit: &mut ()) {}
fn close(&self) {
self.fetch_o... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 8a7e57786a5dca139f5b4261685e22991ded0859 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8a7e57786a5dca139f5b4261685e22991ded0859/tokio/src/sync/mpsc/chan.rs | 481 | 497 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:1 | use crate::loom::{cell::CausalCell, future::AtomicWaker, sync::atomic::AtomicUsize, sync::Arc};
use crate::sync::mpsc::list;
use std::fmt;
use std::process;
use std::sync::atomic::Ordering::{AcqRel, Relaxed};
use std::task::Poll::{Pending, Ready};
use std::task::{Context, Poll};
/// Channel sender
pub(crate) struct T... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | a6253ed05a1e0d14bc64915f5937c29092df9497 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a6253ed05a1e0d14bc64915f5937c29092df9497/tokio/src/sync/mpsc/chan.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:2 | }
#[derive(Debug, Eq, PartialEq)]
pub(crate) enum TrySendError {
Closed,
NoPermits,
}
pub(crate) trait Semaphore {
type Permit;
fn new_permit() -> Self::Permit;
/// The permit is dropped without a value being sent. In this case, the
/// permit must be returned to the semaphore.
fn drop_p... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | a6253ed05a1e0d14bc64915f5937c29092df9497 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a6253ed05a1e0d14bc64915f5937c29092df9497/tokio/src/sync/mpsc/chan.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:3 | semaphore: S,
/// Receiver waker. Notified when a value is pushed into the channel.
rx_waker: AtomicWaker,
/// Tracks the number of outstanding sender handles.
///
/// When this drops to zero, the send half of the channel is closed.
tx_count: AtomicUsize,
/// Only accessed by `Rx` handle.... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | a6253ed05a1e0d14bc64915f5937c29092df9497 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a6253ed05a1e0d14bc64915f5937c29092df9497/tokio/src/sync/mpsc/chan.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:4 | fmt.debug_struct("RxFields")
.field("list", &self.list)
.field("rx_closed", &self.rx_closed)
.finish()
}
}
unsafe impl<T: Send, S: Send> Send for Chan<T, S> {}
unsafe impl<T: Send, S: Sync> Sync for Chan<T, S> {}
pub(crate) fn channel<T, S>(semaphore: S) -> (Tx<T, S>, Rx<T, S>)... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | a6253ed05a1e0d14bc64915f5937c29092df9497 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a6253ed05a1e0d14bc64915f5937c29092df9497/tokio/src/sync/mpsc/chan.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:5 | }
}
pub(crate) fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), ()>> {
self.inner.semaphore.poll_acquire(cx, &mut self.permit)
}
/// Send a message and notify the receiver.
pub(crate) fn try_send(&mut self, value: T) -> Result<(), (T, TrySendError)> {
if let Err(e)... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | a6253ed05a1e0d14bc64915f5937c29092df9497 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a6253ed05a1e0d14bc64915f5937c29092df9497/tokio/src/sync/mpsc/chan.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:6 | }
impl<T, S> Drop for Tx<T, S>
where
S: Semaphore,
{
fn drop(&mut self) {
self.inner.semaphore.drop_permit(&mut self.permit);
if self.inner.tx_count.fetch_sub(1, AcqRel) != 1 {
return;
}
// Close the list, which sends a `Close` message
self.inner.tx.close()... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | a6253ed05a1e0d14bc64915f5937c29092df9497 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a6253ed05a1e0d14bc64915f5937c29092df9497/tokio/src/sync/mpsc/chan.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:7 | });
self.inner.semaphore.close();
}
/// Receive the next value
pub(crate) fn recv(&mut self, cx: &mut Context<'_>) -> Poll<Option<T>> {
use super::block::Read::*;
self.inner.rx_fields.with_mut(|rx_fields_ptr| {
let rx_fields = unsafe { &mut *rx_fields_ptr };
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | a6253ed05a1e0d14bc64915f5937c29092df9497 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a6253ed05a1e0d14bc64915f5937c29092df9497/tokio/src/sync/mpsc/chan.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:8 | // second time here.
try_recv!();
debug!(
"recv; rx_closed = {:?}; is_idle = {:?}",
rx_fields.rx_closed,
self.inner.semaphore.is_idle()
);
if rx_fields.rx_closed && self.inner.semaphore.is_idle() {
Ready(No... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | a6253ed05a1e0d14bc64915f5937c29092df9497 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a6253ed05a1e0d14bc64915f5937c29092df9497/tokio/src/sync/mpsc/chan.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:9 | fn drop(&mut self) {
use super::block::Read::Value;
// Safety: the only owner of the rx fields is Chan, and eing
// inside its own Drop means we're the last ones to touch it.
self.rx_fields.with_mut(|rx_fields_ptr| {
let rx_fields = unsafe { &mut *rx_fields_ptr };
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | a6253ed05a1e0d14bc64915f5937c29092df9497 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a6253ed05a1e0d14bc64915f5937c29092df9497/tokio/src/sync/mpsc/chan.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:10 | permit.release(&self.0);
}
fn add_permit(&self) {
self.0.add_permits(1)
}
fn is_idle(&self) -> bool {
self.0.available_permits() == self.1
}
fn poll_acquire(&self, cx: &mut Context<'_>, permit: &mut Permit) -> Poll<Result<(), ()>> {
permit.poll_acquire(cx, &self.0).map... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | a6253ed05a1e0d14bc64915f5937c29092df9497 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a6253ed05a1e0d14bc64915f5937c29092df9497/tokio/src/sync/mpsc/chan.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:11 | fn add_permit(&self) {
let prev = self.fetch_sub(2, Release);
if prev >> 1 == 0 {
// Something went wrong
process::abort();
}
}
fn is_idle(&self) -> bool {
self.load(Acquire) >> 1 == 0
}
fn poll_acquire(&self, _cx: &mut Context<'_>, permit: &mut... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | a6253ed05a1e0d14bc64915f5937c29092df9497 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a6253ed05a1e0d14bc64915f5937c29092df9497/tokio/src/sync/mpsc/chan.rs | 401 | 447 |
tokio-rs/tokio:tokio/src/sync/mpsc/error.rs:1 | //! Channel error types.
use std::error::Error;
use std::fmt;
/// Error returned by [`Sender::send`](super::Sender::send).
#[derive(PartialEq, Eq, Clone, Copy)]
pub struct SendError<T>(pub T);
impl<T> fmt::Debug for SendError<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct(... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/error.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/mpsc/error.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/sync/mpsc/error.rs:2 | match self {
TrySendError::Full(val) => val,
TrySendError::Closed(val) => val,
}
}
}
impl<T> fmt::Debug for TrySendError<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self {
TrySendError::Full(..) => "Full(..)".fmt(f),
Try... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/error.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/mpsc/error.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/sync/mpsc/error.rs:3 | #[derive(PartialEq, Eq, Clone, Copy, Debug)]
pub enum TryRecvError {
/// This **channel** is currently empty, but the **Sender**(s) have not yet
/// disconnected, so data may yet become available.
Empty,
/// The **channel**'s sending half has become disconnected, and there will
/// never be any more... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/error.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/mpsc/error.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/sync/mpsc/error.rs:4 | // ===== SendTimeoutError =====
#[derive(PartialEq, Eq, Clone, Copy)]
/// Error returned by [`Sender::send_timeout`](super::Sender::send_timeout).
pub enum SendTimeoutError<T> {
/// The data could not be sent on the channel because the channel is
/// full, and the timeout to send has elapse... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/error.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/mpsc/error.rs | 121 | 168 |
tokio-rs/tokio:tokio/src/sync/mpsc/error.rs:1 | //! Channel error types.
use std::error::Error;
use std::fmt;
/// Error returned by the `Sender`.
#[derive(PartialEq, Eq, Clone, Copy)]
pub struct SendError<T>(pub T);
impl<T> fmt::Debug for SendError<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("SendError").finish_non_e... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/error.rs | MIT | a491b16a89f6df83efaf8d00de0786d6aeaec6b7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a491b16a89f6df83efaf8d00de0786d6aeaec6b7/tokio/src/sync/mpsc/error.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/sync/mpsc/error.rs:2 | pub fn into_inner(self) -> T {
match self {
TrySendError::Full(val) => val,
TrySendError::Closed(val) => val,
}
}
}
impl<T> fmt::Debug for TrySendError<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self {
TrySendError::Full(..... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/error.rs | MIT | a491b16a89f6df83efaf8d00de0786d6aeaec6b7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a491b16a89f6df83efaf8d00de0786d6aeaec6b7/tokio/src/sync/mpsc/error.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/sync/mpsc/error.rs:3 | /// Error returned by `try_recv`.
#[derive(PartialEq, Eq, Clone, Copy, Debug)]
pub enum TryRecvError {
/// This **channel** is currently empty, but the **Sender**(s) have not yet
/// disconnected, so data may yet become available.
Empty,
/// The **channel**'s sending half has become disconnected, and th... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/error.rs | MIT | a491b16a89f6df83efaf8d00de0786d6aeaec6b7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a491b16a89f6df83efaf8d00de0786d6aeaec6b7/tokio/src/sync/mpsc/error.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/sync/mpsc/error.rs:4 | cfg_time! {
// ===== SendTimeoutError =====
#[derive(PartialEq, Eq, Clone, Copy)]
/// Error returned by [`Sender::send_timeout`](super::Sender::send_timeout)].
pub enum SendTimeoutError<T> {
/// The data could not be sent on the channel because the channel is
/// full, and the timeout t... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/error.rs | MIT | a491b16a89f6df83efaf8d00de0786d6aeaec6b7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a491b16a89f6df83efaf8d00de0786d6aeaec6b7/tokio/src/sync/mpsc/error.rs | 121 | 169 |
tokio-rs/tokio:tokio/src/sync/mpsc/error.rs:1 | //! Channel error types.
use std::error::Error;
use std::fmt;
/// Error returned by the `Sender`.
#[derive(PartialEq, Eq, Clone, Copy)]
pub struct SendError<T>(pub T);
impl<T> fmt::Debug for SendError<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("SendError").finish_non_e... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/error.rs | MIT | 131e7b4e49c8849298ba54b4e0c99f4b81d869e3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/131e7b4e49c8849298ba54b4e0c99f4b81d869e3/tokio/src/sync/mpsc/error.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/sync/mpsc/error.rs:2 | match *self {
TrySendError::Full(..) => "Full(..)".fmt(f),
TrySendError::Closed(..) => "Closed(..)".fmt(f),
}
}
}
impl<T> fmt::Display for TrySendError<T> {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
fmt,
"{}",
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/error.rs | MIT | 131e7b4e49c8849298ba54b4e0c99f4b81d869e3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/131e7b4e49c8849298ba54b4e0c99f4b81d869e3/tokio/src/sync/mpsc/error.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/sync/mpsc/error.rs:3 | impl fmt::Display for TryRecvError {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self {
TryRecvError::Empty => "receiving on an empty channel".fmt(fmt),
TryRecvError::Disconnected => "receiving on a closed channel".fmt(fmt),
}
}
}
impl Error for T... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/error.rs | MIT | 131e7b4e49c8849298ba54b4e0c99f4b81d869e3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/131e7b4e49c8849298ba54b4e0c99f4b81d869e3/tokio/src/sync/mpsc/error.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/sync/mpsc/error.rs:4 | /// The receive half of the channel was explicitly closed or has been
/// dropped.
Closed(T),
}
impl<T> fmt::Debug for SendTimeoutError<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self {
SendTimeoutError::Timeout(..) => "Timeout(..)... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/error.rs | MIT | 131e7b4e49c8849298ba54b4e0c99f4b81d869e3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/131e7b4e49c8849298ba54b4e0c99f4b81d869e3/tokio/src/sync/mpsc/error.rs | 121 | 149 |
tokio-rs/tokio:tokio/src/sync/mpsc/error.rs:1 | //! Channel error types.
use std::error::Error;
use std::fmt;
/// Error returned by the `Sender`.
#[derive(PartialEq, Eq, Clone, Copy)]
pub struct SendError<T>(pub T);
impl<T> fmt::Debug for SendError<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("SendError").finish_non_e... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/error.rs | MIT | d8847cf89171e8b7872195724830a276c421f63e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d8847cf89171e8b7872195724830a276c421f63e/tokio/src/sync/mpsc/error.rs | 1 | 60 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.