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:7 | impl<T, S: Semaphore> Rx<T, S> {
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 | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/mpsc/chan.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:8 | pub(crate) fn len(&self) -> usize {
self.inner.rx_fields.with(|rx_fields_ptr| {
let rx_fields = unsafe { &*rx_fields_ptr };
rx_fields.list.len(&self.inner.tx)
})
}
/// Receive the next value
pub(crate) fn recv(&mut self, cx: &mut Context<'_>) -> Poll<Option<T>> {
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/mpsc/chan.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:9 | try_recv!();
self.inner.rx_waker.register_by_ref(cx.waker());
// 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_c... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/mpsc/chan.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:10 | let mut remaining = limit;
let initial_length = buffer.len();
self.inner.rx_fields.with_mut(|rx_fields_ptr| {
let rx_fields = unsafe { &mut *rx_fields_ptr };
macro_rules! try_recv {
() => {
while remaining > 0 {
match r... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/mpsc/chan.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:11 | };
}
try_recv!();
self.inner.rx_waker.register_by_ref(cx.waker());
// 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!();
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/mpsc/chan.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:12 | {
return Err(TryRecvError::Disconnected)
}
TryPopResult::Empty => return Err(TryRecvError::Empty),
TryPopResult::Busy => {} // fall through
}
};
}
try_recv!();... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/mpsc/chan.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:13 | pub(super) fn sender_weak_count(&self) -> usize {
self.inner.tx_weak_count.load(Relaxed)
}
}
impl<T, S: Semaphore> Drop for Rx<T, S> {
fn drop(&mut self) {
use super::block::Read::Value;
self.close();
self.inner.rx_fields.with_mut(|rx_fields_ptr| {
let rx_fields = ... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/mpsc/chan.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:14 | guard.drain();
});
}
}
// ===== impl Chan =====
impl<T, S> Chan<T, S> {
fn send(&self, value: T) {
// Push the value
self.tx.push(value);
// Notify the rx task
self.rx_waker.wake();
}
pub(super) fn decrement_weak_count(&self) {
self.tx_weak_count.fetch... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/mpsc/chan.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:15 | 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() };
});
}
}
// ===== impl Semaphore for (::Semaphore, capacity) =====
impl Semaphor... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/mpsc/chan.rs | 561 | 620 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:16 | // Something went wrong
process::abort();
}
}
fn add_permits(&self, n: usize) {
let prev = self.0.fetch_sub(n << 1, Release);
if (prev >> 1) < n {
// Something went wrong
process::abort();
}
}
fn is_idle(&self) -> bool {
self... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/mpsc/chan.rs | 601 | 626 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:7 | impl<T, S: Semaphore> Rx<T, S> {
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 | 9fccf5339d41c1f2f863f97b9133bc8a5a10bc28 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9fccf5339d41c1f2f863f97b9133bc8a5a10bc28/tokio/src/sync/mpsc/chan.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:8 | pub(crate) fn len(&self) -> usize {
self.inner.rx_fields.with(|rx_fields_ptr| {
let rx_fields = unsafe { &*rx_fields_ptr };
rx_fields.list.len(&self.inner.tx)
})
}
/// Receive the next value
pub(crate) fn recv(&mut self, cx: &mut Context<'_>) -> Poll<Option<T>> {
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 9fccf5339d41c1f2f863f97b9133bc8a5a10bc28 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9fccf5339d41c1f2f863f97b9133bc8a5a10bc28/tokio/src/sync/mpsc/chan.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:9 | try_recv!();
self.inner.rx_waker.register_by_ref(cx.waker());
// 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_c... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 9fccf5339d41c1f2f863f97b9133bc8a5a10bc28 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9fccf5339d41c1f2f863f97b9133bc8a5a10bc28/tokio/src/sync/mpsc/chan.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:11 | };
}
try_recv!();
self.inner.rx_waker.register_by_ref(cx.waker());
// 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!();
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | bf18ed452d6aae438e84ae008a01a74776abdc19 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/bf18ed452d6aae438e84ae008a01a74776abdc19/tokio/src/sync/mpsc/chan.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:12 | }
TryPopResult::Empty => return Err(TryRecvError::Empty),
TryPopResult::Busy => {} // fall through
}
};
}
try_recv!();
// If a previous `poll_recv` call has set a waker, we wake it here.
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | bf18ed452d6aae438e84ae008a01a74776abdc19 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/bf18ed452d6aae438e84ae008a01a74776abdc19/tokio/src/sync/mpsc/chan.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:13 | self.inner.tx_weak_count.load(Relaxed)
}
}
impl<T, S: Semaphore> Drop for Rx<T, S> {
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 };
struct Guard<'... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | bf18ed452d6aae438e84ae008a01a74776abdc19 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/bf18ed452d6aae438e84ae008a01a74776abdc19/tokio/src/sync/mpsc/chan.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:14 | });
}
}
// ===== impl Chan =====
impl<T, S> Chan<T, S> {
fn send(&self, value: T) {
// Push the value
self.tx.push(value);
// Notify the rx task
self.rx_waker.wake();
}
pub(super) fn decrement_weak_count(&self) {
self.tx_weak_count.fetch_sub(1, Relaxed);
}... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | bf18ed452d6aae438e84ae008a01a74776abdc19 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/bf18ed452d6aae438e84ae008a01a74776abdc19/tokio/src/sync/mpsc/chan.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:15 | while let Some(Value(_)) = rx_fields.list.pop(&self.tx) {}
unsafe { rx_fields.list.free_blocks() };
});
}
}
// ===== impl Semaphore for (::Semaphore, capacity) =====
impl Semaphore for bounded::Semaphore {
fn add_permit(&self) {
self.semaphore.release(1);
}
fn add_permits(... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | bf18ed452d6aae438e84ae008a01a74776abdc19 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/bf18ed452d6aae438e84ae008a01a74776abdc19/tokio/src/sync/mpsc/chan.rs | 561 | 620 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:16 | }
}
fn add_permits(&self, n: usize) {
let prev = self.0.fetch_sub(n << 1, Release);
if (prev >> 1) < n {
// Something went wrong
process::abort();
}
}
fn is_idle(&self) -> bool {
self.0.load(Acquire) >> 1 == 0
}
fn close(&self) {
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | bf18ed452d6aae438e84ae008a01a74776abdc19 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/bf18ed452d6aae438e84ae008a01a74776abdc19/tokio/src/sync/mpsc/chan.rs | 601 | 624 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:7 | impl<T, S: Semaphore> Rx<T, S> {
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 | 484cb52d8d21cb8156decbeba9569651fcc09d0d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/484cb52d8d21cb8156decbeba9569651fcc09d0d/tokio/src/sync/mpsc/chan.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:8 | pub(crate) fn len(&self) -> usize {
self.inner.rx_fields.with(|rx_fields_ptr| {
let rx_fields = unsafe { &*rx_fields_ptr };
rx_fields.list.len(&self.inner.tx)
})
}
/// Receive the next value
pub(crate) fn recv(&mut self, cx: &mut Context<'_>) -> Poll<Option<T>> {
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 484cb52d8d21cb8156decbeba9569651fcc09d0d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/484cb52d8d21cb8156decbeba9569651fcc09d0d/tokio/src/sync/mpsc/chan.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:9 | };
}
try_recv!();
self.inner.rx_waker.register_by_ref(cx.waker());
// 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!();
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 484cb52d8d21cb8156decbeba9569651fcc09d0d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/484cb52d8d21cb8156decbeba9569651fcc09d0d/tokio/src/sync/mpsc/chan.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:10 | return Ready(0usize);
}
let mut remaining = limit;
let initial_length = buffer.len();
self.inner.rx_fields.with_mut(|rx_fields_ptr| {
let rx_fields = unsafe { &mut *rx_fields_ptr };
macro_rules! try_recv {
() => {
while remain... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 484cb52d8d21cb8156decbeba9569651fcc09d0d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/484cb52d8d21cb8156decbeba9569651fcc09d0d/tokio/src/sync/mpsc/chan.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:11 | self.inner.semaphore.add_permits(number_added);
coop.made_progress();
return Ready(number_added);
}
};
}
try_recv!();
self.inner.rx_waker.register_by_ref(cx.waker());
// It is possible ... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 484cb52d8d21cb8156decbeba9569651fcc09d0d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/484cb52d8d21cb8156decbeba9569651fcc09d0d/tokio/src/sync/mpsc/chan.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:12 | TryPopResult::Closed => return Err(TryRecvError::Disconnected),
// If close() was called, an empty queue should report Disconnected.
TryPopResult::Empty if rx_fields.rx_closed => {
return Err(TryRecvError::Disconnected)
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 484cb52d8d21cb8156decbeba9569651fcc09d0d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/484cb52d8d21cb8156decbeba9569651fcc09d0d/tokio/src/sync/mpsc/chan.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:13 | self.inner.tx_count.load(Acquire)
}
pub(super) fn sender_weak_count(&self) -> usize {
self.inner.tx_weak_count.load(Relaxed)
}
}
impl<T, S: Semaphore> Drop for Rx<T, S> {
fn drop(&mut self) {
use super::block::Read::Value;
self.close();
self.inner.rx_fields.with_mut(|... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 484cb52d8d21cb8156decbeba9569651fcc09d0d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/484cb52d8d21cb8156decbeba9569651fcc09d0d/tokio/src/sync/mpsc/chan.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:14 | self.tx_weak_count.fetch_add(1, Relaxed);
}
pub(super) fn strong_count(&self) -> usize {
self.tx_count.load(Acquire)
}
pub(super) fn weak_count(&self) -> usize {
self.tx_weak_count.load(Relaxed)
}
}
impl<T, S> Drop for Chan<T, S> {
fn drop(&mut self) {
use super::block... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 484cb52d8d21cb8156decbeba9569651fcc09d0d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/484cb52d8d21cb8156decbeba9569651fcc09d0d/tokio/src/sync/mpsc/chan.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:15 | }
fn close(&self) {
self.semaphore.close();
}
fn is_closed(&self) -> bool {
self.semaphore.is_closed()
}
}
// ===== impl Semaphore for AtomicUsize =====
impl Semaphore for unbounded::Semaphore {
fn add_permit(&self) {
let prev = self.0.fetch_sub(2, Release);
if p... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 484cb52d8d21cb8156decbeba9569651fcc09d0d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/484cb52d8d21cb8156decbeba9569651fcc09d0d/tokio/src/sync/mpsc/chan.rs | 561 | 604 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:8 | pub(crate) fn len(&self) -> usize {
self.inner.rx_fields.with(|rx_fields_ptr| {
let rx_fields = unsafe { &*rx_fields_ptr };
rx_fields.list.len(&self.inner.tx)
})
}
/// Receive the next value
pub(crate) fn recv(&mut self, cx: &mut Context<'_>) -> Poll<Option<T>> {
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | d060401f6c7dca4a20674e3ad63ad7f1b228aa31 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d060401f6c7dca4a20674e3ad63ad7f1b228aa31/tokio/src/sync/mpsc/chan.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:9 | };
}
try_recv!();
self.inner.rx_waker.register_by_ref(cx.waker());
// 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!();
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | d060401f6c7dca4a20674e3ad63ad7f1b228aa31 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d060401f6c7dca4a20674e3ad63ad7f1b228aa31/tokio/src/sync/mpsc/chan.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:12 | TryPopResult::Closed => return Err(TryRecvError::Disconnected),
// If close() was called, an empty queue should report Disconnected.
TryPopResult::Empty if rx_fields.rx_closed => {
return Err(TryRecvError::Disconnected)
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | d060401f6c7dca4a20674e3ad63ad7f1b228aa31 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d060401f6c7dca4a20674e3ad63ad7f1b228aa31/tokio/src/sync/mpsc/chan.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:13 | self.inner.tx_count.load(Acquire)
}
pub(super) fn sender_weak_count(&self) -> usize {
self.inner.tx_weak_count.load(Relaxed)
}
}
impl<T, S: Semaphore> Drop for Rx<T, S> {
fn drop(&mut self) {
use super::block::Read::Value;
self.close();
self.inner.rx_fields.with_mut(|... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | d060401f6c7dca4a20674e3ad63ad7f1b228aa31 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d060401f6c7dca4a20674e3ad63ad7f1b228aa31/tokio/src/sync/mpsc/chan.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:14 | sem: &self.inner.semaphore,
};
guard.drain();
});
}
}
// ===== impl Chan =====
impl<T, S> Chan<T, S> {
fn send(&self, value: T) {
// Push the value
self.tx.push(value);
// Notify the rx task
self.rx_waker.wake();
}
pub(super) fn decrem... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | d060401f6c7dca4a20674e3ad63ad7f1b228aa31 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d060401f6c7dca4a20674e3ad63ad7f1b228aa31/tokio/src/sync/mpsc/chan.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:15 | // Safety: the only owner of the rx fields is Chan, and being
// 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 };
while let Some(Value(_)) = rx_fields.list.pop(&self.tx) {}
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | d060401f6c7dca4a20674e3ad63ad7f1b228aa31 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d060401f6c7dca4a20674e3ad63ad7f1b228aa31/tokio/src/sync/mpsc/chan.rs | 561 | 620 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:16 | if prev >> 1 == 0 {
// Something went wrong
process::abort();
}
}
fn add_permits(&self, n: usize) {
let prev = self.0.fetch_sub(n << 1, Release);
if (prev >> 1) < n {
// Something went wrong
process::abort();
}
}
fn is_id... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | d060401f6c7dca4a20674e3ad63ad7f1b228aa31 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d060401f6c7dca4a20674e3ad63ad7f1b228aa31/tokio/src/sync/mpsc/chan.rs | 601 | 628 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:11 | self.inner.semaphore.add_permits(number_added);
coop.made_progress();
return Ready(number_added);
}
};
}
try_recv!();
self.inner.rx_waker.register_by_ref(cx.waker());
// It is possible ... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 605ef578df04f12a951060dc3b2fb930f6f379fe | github | async-runtime | https://github.com/tokio-rs/tokio/blob/605ef578df04f12a951060dc3b2fb930f6f379fe/tokio/src/sync/mpsc/chan.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:12 | TryPopResult::Closed => return Err(TryRecvError::Disconnected),
TryPopResult::Empty => return Err(TryRecvError::Empty),
TryPopResult::Busy => {} // fall through
}
};
}
try_recv!();
// If a previous ... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 605ef578df04f12a951060dc3b2fb930f6f379fe | github | async-runtime | https://github.com/tokio-rs/tokio/blob/605ef578df04f12a951060dc3b2fb930f6f379fe/tokio/src/sync/mpsc/chan.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:12 | TryPopResult::Closed => return Err(TryRecvError::Disconnected),
TryPopResult::Empty => return Err(TryRecvError::Empty),
TryPopResult::Busy => {} // fall through
}
};
}
try_recv!();
// If a previous ... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 11f66f43a09169b893212b854c6c49985ff2224f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/11f66f43a09169b893212b854c6c49985ff2224f/tokio/src/sync/mpsc/chan.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:13 | self.inner.tx_weak_count.load(Relaxed)
}
}
impl<T, S: Semaphore> Drop for Rx<T, S> {
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 Som... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 11f66f43a09169b893212b854c6c49985ff2224f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/11f66f43a09169b893212b854c6c49985ff2224f/tokio/src/sync/mpsc/chan.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:14 | self.tx_count.load(Acquire)
}
pub(super) fn weak_count(&self) -> usize {
self.tx_weak_count.load(Relaxed)
}
}
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 being
// inside it... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 11f66f43a09169b893212b854c6c49985ff2224f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/11f66f43a09169b893212b854c6c49985ff2224f/tokio/src/sync/mpsc/chan.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:15 | }
fn is_closed(&self) -> bool {
self.semaphore.is_closed()
}
}
// ===== impl Semaphore for AtomicUsize =====
impl Semaphore for unbounded::Semaphore {
fn add_permit(&self) {
let prev = self.0.fetch_sub(2, Release);
if prev >> 1 == 0 {
// Something went wrong
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 11f66f43a09169b893212b854c6c49985ff2224f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/11f66f43a09169b893212b854c6c49985ff2224f/tokio/src/sync/mpsc/chan.rs | 561 | 600 |
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::runtime::park::CachedParkThread;
use crate::sync::mpsc::error::TryRecvError;
use crate::sync::mpsc::{bounded, list, unbounded};
use crate::sync::notify::Notify;
use... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 9bd6702a3f52c71ab687170f6aeab6142d2282d0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9bd6702a3f52c71ab687170f6aeab6142d2282d0/tokio/src/sync/mpsc/chan.rs | 1 | 60 |
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::runtime::park::CachedParkThread;
use crate::sync::mpsc::error::TryRecvError;
use crate::sync::mpsc::{bounded, list, unbounded};
use crate::sync::notify::Notify;
use... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | fe7285d3d167e7b0ff611d7dfc99fe8b00932015 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fe7285d3d167e7b0ff611d7dfc99fe8b00932015/tokio/src/sync/mpsc/chan.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:2 | fn add_permit(&self);
fn add_permits(&self, n: usize);
fn close(&self);
fn is_closed(&self) -> bool;
}
pub(super) struct Chan<T, S> {
/// Handle to the push half of the lock-free list.
tx: CachePadded<list::Tx<T>>,
/// Receiver waker. Notified when a value is pushed into the channel.
rx... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | fe7285d3d167e7b0ff611d7dfc99fe8b00932015 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fe7285d3d167e7b0ff611d7dfc99fe8b00932015/tokio/src/sync/mpsc/chan.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:3 | fmt.debug_struct("Chan")
.field("tx", &*self.tx)
.field("semaphore", &self.semaphore)
.field("rx_waker", &*self.rx_waker)
.field("tx_count", &self.tx_count)
.field("rx_fields", &"...")
.finish()
}
}
/// Fields only accessed by `Rx` handle.
str... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | fe7285d3d167e7b0ff611d7dfc99fe8b00932015 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fe7285d3d167e7b0ff611d7dfc99fe8b00932015/tokio/src/sync/mpsc/chan.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:4 | tx_weak_count: AtomicUsize::new(0),
rx_fields: UnsafeCell::new(RxFields {
list: rx,
rx_closed: false,
}),
});
(Tx::new(chan.clone()), Rx::new(chan))
}
// ===== impl Tx =====
impl<T, S> Tx<T, S> {
fn new(chan: Arc<Chan<T, S>>) -> Tx<T, S> {
Tx { inner: chan ... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | fe7285d3d167e7b0ff611d7dfc99fe8b00932015 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fe7285d3d167e7b0ff611d7dfc99fe8b00932015/tokio/src/sync/mpsc/chan.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:5 | match chan
.tx_count
.compare_exchange_weak(tx_count, tx_count + 1, AcqRel, Acquire)
{
Ok(_) => return Some(Tx { inner: chan }),
Err(prev_count) => tx_count = prev_count,
}
}
}
pub(super) fn semaphore(&self) -> &S {... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | fe7285d3d167e7b0ff611d7dfc99fe8b00932015 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fe7285d3d167e7b0ff611d7dfc99fe8b00932015/tokio/src/sync/mpsc/chan.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:6 | let notified = self.inner.notify_rx_closed.notified();
if self.inner.semaphore.is_closed() {
return;
}
notified.await;
}
}
impl<T, S> Clone for Tx<T, S> {
fn clone(&self) -> Tx<T, S> {
// Using a Relaxed ordering here is sufficient as the caller holds a
// s... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | fe7285d3d167e7b0ff611d7dfc99fe8b00932015 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fe7285d3d167e7b0ff611d7dfc99fe8b00932015/tokio/src/sync/mpsc/chan.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:7 | }
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 {
return;
}
rx_fields.rx_closed = true;
});
self.inner.semaphore.close... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | fe7285d3d167e7b0ff611d7dfc99fe8b00932015 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fe7285d3d167e7b0ff611d7dfc99fe8b00932015/tokio/src/sync/mpsc/chan.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:8 | rx_fields.list.len(&self.inner.tx)
})
}
/// Receive the next value
pub(crate) fn recv(&mut self, cx: &mut Context<'_>) -> Poll<Option<T>> {
use super::block::Read;
ready!(crate::trace::trace_leaf(cx));
// Keep track of task budget
let coop = ready!(crate::runtime::... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | fe7285d3d167e7b0ff611d7dfc99fe8b00932015 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fe7285d3d167e7b0ff611d7dfc99fe8b00932015/tokio/src/sync/mpsc/chan.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:9 | try_recv!();
self.inner.rx_waker.register_by_ref(cx.waker());
// 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_c... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | fe7285d3d167e7b0ff611d7dfc99fe8b00932015 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fe7285d3d167e7b0ff611d7dfc99fe8b00932015/tokio/src/sync/mpsc/chan.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:10 | let mut remaining = limit;
let initial_length = buffer.len();
self.inner.rx_fields.with_mut(|rx_fields_ptr| {
let rx_fields = unsafe { &mut *rx_fields_ptr };
macro_rules! try_recv {
() => {
while remaining > 0 {
match r... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | fe7285d3d167e7b0ff611d7dfc99fe8b00932015 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fe7285d3d167e7b0ff611d7dfc99fe8b00932015/tokio/src/sync/mpsc/chan.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:11 | }
};
}
try_recv!();
self.inner.rx_waker.register_by_ref(cx.waker());
// 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.
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | fe7285d3d167e7b0ff611d7dfc99fe8b00932015 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fe7285d3d167e7b0ff611d7dfc99fe8b00932015/tokio/src/sync/mpsc/chan.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:12 | }
};
}
try_recv!();
// If a previous `poll_recv` call has set a waker, we wake it here.
// This allows us to put our own CachedParkThread waker in the
// AtomicWaker slot instead.
//
// This is not a spurious wakeup to... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | fe7285d3d167e7b0ff611d7dfc99fe8b00932015 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fe7285d3d167e7b0ff611d7dfc99fe8b00932015/tokio/src/sync/mpsc/chan.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:13 | impl<T, S: Semaphore> Drop for Rx<T, S> {
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)... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | fe7285d3d167e7b0ff611d7dfc99fe8b00932015 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fe7285d3d167e7b0ff611d7dfc99fe8b00932015/tokio/src/sync/mpsc/chan.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:14 | pub(super) fn weak_count(&self) -> usize {
self.tx_weak_count.load(Relaxed)
}
}
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 being
// inside its own Drop means we're the last ones to... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | fe7285d3d167e7b0ff611d7dfc99fe8b00932015 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fe7285d3d167e7b0ff611d7dfc99fe8b00932015/tokio/src/sync/mpsc/chan.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:15 | self.semaphore.is_closed()
}
}
// ===== impl Semaphore for AtomicUsize =====
impl Semaphore for unbounded::Semaphore {
fn add_permit(&self) {
let prev = self.0.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 | fe7285d3d167e7b0ff611d7dfc99fe8b00932015 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fe7285d3d167e7b0ff611d7dfc99fe8b00932015/tokio/src/sync/mpsc/chan.rs | 561 | 597 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:12 | }
};
}
try_recv!();
// If a previous `poll_recv` call has set a waker, we wake it here.
// This allows us to put our own CachedParkThread waker in the
// AtomicWaker slot instead.
//
// This is not a spurious wakeup to... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | b7d4fba70755e2ec682665f22f630b8a725a3705 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b7d4fba70755e2ec682665f22f630b8a725a3705/tokio/src/sync/mpsc/chan.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:13 | 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> {
fn send(&self, value: T) {
// Push the value
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | b7d4fba70755e2ec682665f22f630b8a725a3705 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b7d4fba70755e2ec682665f22f630b8a725a3705/tokio/src/sync/mpsc/chan.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:15 | let prev = self.0.fetch_sub(2, Release);
if prev >> 1 == 0 {
// Something went wrong
process::abort();
}
}
fn add_permits(&self, n: usize) {
let prev = self.0.fetch_sub(n << 1, Release);
if (prev >> 1) < n {
// Something went wrong
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | b7d4fba70755e2ec682665f22f630b8a725a3705 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b7d4fba70755e2ec682665f22f630b8a725a3705/tokio/src/sync/mpsc/chan.rs | 561 | 589 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:12 | }
};
}
try_recv!();
// If a previous `poll_recv` call has set a waker, we wake it here.
// This allows us to put our own CachedParkThread waker in the
// AtomicWaker slot instead.
//
// This is not a spurious wakeup to... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 3ce4720a4532e40c78f7d851b1cfb8ea26542177 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3ce4720a4532e40c78f7d851b1cfb8ea26542177/tokio/src/sync/mpsc/chan.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:13 | }
});
}
}
// ===== impl Chan =====
impl<T, S> Chan<T, S> {
fn send(&self, value: T) {
// Push the value
self.tx.push(value);
// Notify the rx task
self.rx_waker.wake();
}
pub(super) fn decrement_weak_count(&self) {
self.tx_weak_count.fetch_sub(1, Relax... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 3ce4720a4532e40c78f7d851b1cfb8ea26542177 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3ce4720a4532e40c78f7d851b1cfb8ea26542177/tokio/src/sync/mpsc/chan.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:14 | let rx_fields = unsafe { &mut *rx_fields_ptr };
while let Some(Value(_)) = rx_fields.list.pop(&self.tx) {}
unsafe { rx_fields.list.free_blocks() };
});
}
}
// ===== impl Semaphore for (::Semaphore, capacity) =====
impl Semaphore for bounded::Semaphore {
fn add_permit(&self) {
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 3ce4720a4532e40c78f7d851b1cfb8ea26542177 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3ce4720a4532e40c78f7d851b1cfb8ea26542177/tokio/src/sync/mpsc/chan.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:15 | process::abort();
}
}
fn add_permits(&self, n: usize) {
let prev = self.0.fetch_sub(n << 1, Release);
if (prev >> 1) < n {
// Something went wrong
process::abort();
}
}
fn is_idle(&self) -> bool {
self.0.load(Acquire) >> 1 == 0
}
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 3ce4720a4532e40c78f7d851b1cfb8ea26542177 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3ce4720a4532e40c78f7d851b1cfb8ea26542177/tokio/src/sync/mpsc/chan.rs | 561 | 585 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:6 | let notified = self.inner.notify_rx_closed.notified();
if self.inner.semaphore.is_closed() {
return;
}
notified.await;
}
}
impl<T, S> Clone for Tx<T, S> {
fn clone(&self) -> Tx<T, S> {
// Using a Relaxed ordering here is sufficient as the caller holds a
// s... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 1846483f1953f6ac4dd89f434e78ff99eb0c92f9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1846483f1953f6ac4dd89f434e78ff99eb0c92f9/tokio/src/sync/mpsc/chan.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:7 | }
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 {
return;
}
rx_fields.rx_closed = true;
});
self.inner.semaphore.close... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 1846483f1953f6ac4dd89f434e78ff99eb0c92f9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1846483f1953f6ac4dd89f434e78ff99eb0c92f9/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 | 1846483f1953f6ac4dd89f434e78ff99eb0c92f9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1846483f1953f6ac4dd89f434e78ff99eb0c92f9/tokio/src/sync/mpsc/chan.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:9 | ) -> Poll<usize> {
use super::block::Read;
ready!(crate::trace::trace_leaf(cx));
// Keep track of task budget
let coop = ready!(crate::runtime::coop::poll_proceed(cx));
if limit == 0 {
coop.made_progress();
return Ready(0usize);
}
let m... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 1846483f1953f6ac4dd89f434e78ff99eb0c92f9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1846483f1953f6ac4dd89f434e78ff99eb0c92f9/tokio/src/sync/mpsc/chan.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:10 | return Ready(number_added);
}
None => {
break; // fall through
}
}
}
let number_added = buffer.len() - initial_length;
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 1846483f1953f6ac4dd89f434e78ff99eb0c92f9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1846483f1953f6ac4dd89f434e78ff99eb0c92f9/tokio/src/sync/mpsc/chan.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:11 | 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.try_pop(&self.inner.tx) {
TryPopResult::Ok(value) => {
sel... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 1846483f1953f6ac4dd89f434e78ff99eb0c92f9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1846483f1953f6ac4dd89f434e78ff99eb0c92f9/tokio/src/sync/mpsc/chan.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:12 | }
impl<T, S: Semaphore> Drop for Rx<T, S> {
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.... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 1846483f1953f6ac4dd89f434e78ff99eb0c92f9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1846483f1953f6ac4dd89f434e78ff99eb0c92f9/tokio/src/sync/mpsc/chan.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:13 | pub(super) fn weak_count(&self) -> usize {
self.tx_weak_count.load(Relaxed)
}
}
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 being
// inside its own Drop means we're the last ones to... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 1846483f1953f6ac4dd89f434e78ff99eb0c92f9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1846483f1953f6ac4dd89f434e78ff99eb0c92f9/tokio/src/sync/mpsc/chan.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:14 | fn is_closed(&self) -> bool {
self.semaphore.is_closed()
}
}
// ===== impl Semaphore for AtomicUsize =====
impl Semaphore for unbounded::Semaphore {
fn add_permit(&self) {
let prev = self.0.fetch_sub(2, Release);
if prev >> 1 == 0 {
// Something went wrong
proc... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 1846483f1953f6ac4dd89f434e78ff99eb0c92f9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1846483f1953f6ac4dd89f434e78ff99eb0c92f9/tokio/src/sync/mpsc/chan.rs | 521 | 558 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:2 | fn add_permit(&self);
fn add_permits(&self, n: usize);
fn close(&self);
fn is_closed(&self) -> bool;
}
pub(super) struct Chan<T, S> {
/// Handle to the push half of the lock-free list.
tx: CachePadded<list::Tx<T>>,
/// Receiver waker. Notified when a value is pushed into the channel.
rx... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 881b510a072f5acd773a10d3be0debf74113404e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/881b510a072f5acd773a10d3be0debf74113404e/tokio/src/sync/mpsc/chan.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:3 | .field("rx_waker", &*self.rx_waker)
.field("tx_count", &self.tx_count)
.field("rx_fields", &"...")
.finish()
}
}
/// Fields only accessed by `Rx` handle.
struct RxFields<T> {
/// Channel receiver. This field is only accessed by the `Receiver` type.
list: list::Rx<T>,
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 881b510a072f5acd773a10d3be0debf74113404e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/881b510a072f5acd773a10d3be0debf74113404e/tokio/src/sync/mpsc/chan.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:4 | }),
});
(Tx::new(chan.clone()), Rx::new(chan))
}
// ===== impl Tx =====
impl<T, S> Tx<T, S> {
fn new(chan: Arc<Chan<T, S>>) -> Tx<T, S> {
Tx { inner: chan }
}
pub(super) fn downgrade(&self) -> Arc<Chan<T, S>> {
self.inner.clone()
}
// Returns the upgraded channel or None... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 881b510a072f5acd773a10d3be0debf74113404e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/881b510a072f5acd773a10d3be0debf74113404e/tokio/src/sync/mpsc/chan.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:5 | /// Send a message and notify the receiver.
pub(crate) fn send(&self, value: T) {
self.inner.send(value);
}
/// Wake the receive half
pub(crate) fn wake_rx(&self) {
self.inner.rx_waker.wake();
}
/// Returns `true` if senders belong to the same channel.
pub(crate) fn same_ch... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 881b510a072f5acd773a10d3be0debf74113404e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/881b510a072f5acd773a10d3be0debf74113404e/tokio/src/sync/mpsc/chan.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:6 | Tx {
inner: self.inner.clone(),
}
}
}
impl<T, S> Drop for Tx<T, S> {
fn drop(&mut self) {
if self.inner.tx_count.fetch_sub(1, AcqRel) != 1 {
return;
}
// Close the list, which sends a `Close` message
self.inner.tx.close();
// Notify the ... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 881b510a072f5acd773a10d3be0debf74113404e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/881b510a072f5acd773a10d3be0debf74113404e/tokio/src/sync/mpsc/chan.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:7 | self.inner.notify_rx_closed.notify_waiters();
}
/// Receive the next value
pub(crate) fn recv(&mut self, cx: &mut Context<'_>) -> Poll<Option<T>> {
use super::block::Read;
ready!(crate::trace::trace_leaf(cx));
// Keep track of task budget
let coop = ready!(crate::runtime::... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 881b510a072f5acd773a10d3be0debf74113404e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/881b510a072f5acd773a10d3be0debf74113404e/tokio/src/sync/mpsc/chan.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:8 | self.inner.rx_waker.register_by_ref(cx.waker());
// 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.semaph... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 881b510a072f5acd773a10d3be0debf74113404e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/881b510a072f5acd773a10d3be0debf74113404e/tokio/src/sync/mpsc/chan.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:9 | let initial_length = buffer.len();
self.inner.rx_fields.with_mut(|rx_fields_ptr| {
let rx_fields = unsafe { &mut *rx_fields_ptr };
macro_rules! try_recv {
() => {
while remaining > 0 {
match rx_fields.list.pop(&self.inner.tx) {... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 881b510a072f5acd773a10d3be0debf74113404e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/881b510a072f5acd773a10d3be0debf74113404e/tokio/src/sync/mpsc/chan.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:10 | };
}
try_recv!();
self.inner.rx_waker.register_by_ref(cx.waker());
// 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!();
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 881b510a072f5acd773a10d3be0debf74113404e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/881b510a072f5acd773a10d3be0debf74113404e/tokio/src/sync/mpsc/chan.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:11 | };
}
try_recv!();
// If a previous `poll_recv` call has set a waker, we wake it here.
// This allows us to put our own CachedParkThread waker in the
// AtomicWaker slot instead.
//
// This is not a spurious wakeup to `poll_recv` since... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 881b510a072f5acd773a10d3be0debf74113404e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/881b510a072f5acd773a10d3be0debf74113404e/tokio/src/sync/mpsc/chan.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:12 | });
}
}
// ===== impl Chan =====
impl<T, S> Chan<T, S> {
fn send(&self, value: T) {
// Push the value
self.tx.push(value);
// Notify the rx task
self.rx_waker.wake();
}
}
impl<T, S> Drop for Chan<T, S> {
fn drop(&mut self) {
use super::block::Read::Value;
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 881b510a072f5acd773a10d3be0debf74113404e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/881b510a072f5acd773a10d3be0debf74113404e/tokio/src/sync/mpsc/chan.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:13 | }
fn is_idle(&self) -> bool {
self.semaphore.available_permits() == self.bound
}
fn close(&self) {
self.semaphore.close();
}
fn is_closed(&self) -> bool {
self.semaphore.is_closed()
}
}
// ===== impl Semaphore for AtomicUsize =====
impl Semaphore for unbounded::Semap... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 881b510a072f5acd773a10d3be0debf74113404e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/881b510a072f5acd773a10d3be0debf74113404e/tokio/src/sync/mpsc/chan.rs | 481 | 528 |
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::runtime::park::CachedParkThread;
use crate::sync::mpsc::error::TryRecvError;
use crate::sync::mpsc::{bounded, list, unbounded};
use crate::sync::notify::Notify;
use... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 6871084629ad95c37c7136d865890ab2e371ea12 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/sync/mpsc/chan.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:2 | fn add_permit(&self);
fn close(&self);
fn is_closed(&self) -> bool;
}
pub(super) struct Chan<T, S> {
/// Handle to the push half of the lock-free list.
tx: CachePadded<list::Tx<T>>,
/// Receiver waker. Notified when a value is pushed into the channel.
rx_waker: CachePadded<AtomicWaker>,
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 6871084629ad95c37c7136d865890ab2e371ea12 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/sync/mpsc/chan.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:3 | .field("rx_fields", &"...")
.finish()
}
}
/// Fields only accessed by `Rx` handle.
struct RxFields<T> {
/// Channel receiver. This field is only accessed by the `Receiver` type.
list: list::Rx<T>,
/// `true` if `Rx::close` is called.
rx_closed: bool,
}
impl<T> fmt::Debug for RxFields<... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 6871084629ad95c37c7136d865890ab2e371ea12 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/sync/mpsc/chan.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:4 | (Tx::new(chan.clone()), Rx::new(chan))
}
// ===== impl Tx =====
impl<T, S> Tx<T, S> {
fn new(chan: Arc<Chan<T, S>>) -> Tx<T, S> {
Tx { inner: chan }
}
pub(super) fn downgrade(&self) -> Arc<Chan<T, S>> {
self.inner.clone()
}
// Returns the upgraded channel or None if the upgrade f... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 6871084629ad95c37c7136d865890ab2e371ea12 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/sync/mpsc/chan.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:5 | pub(crate) fn send(&self, value: T) {
self.inner.send(value);
}
/// Wake the receive half
pub(crate) fn wake_rx(&self) {
self.inner.rx_waker.wake();
}
/// Returns `true` if senders belong to the same channel.
pub(crate) fn same_channel(&self, other: &Self) -> bool {
Arc... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 6871084629ad95c37c7136d865890ab2e371ea12 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/sync/mpsc/chan.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:6 | inner: self.inner.clone(),
}
}
}
impl<T, S> Drop for Tx<T, S> {
fn drop(&mut self) {
if self.inner.tx_count.fetch_sub(1, AcqRel) != 1 {
return;
}
// Close the list, which sends a `Close` message
self.inner.tx.close();
// Notify the receiver
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 6871084629ad95c37c7136d865890ab2e371ea12 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/sync/mpsc/chan.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:7 | /// Receive the next value
pub(crate) fn recv(&mut self, cx: &mut Context<'_>) -> Poll<Option<T>> {
use super::block::Read;
ready!(crate::trace::trace_leaf(cx));
// Keep track of task budget
let coop = ready!(crate::runtime::coop::poll_proceed(cx));
self.inner.rx_fields.wi... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 6871084629ad95c37c7136d865890ab2e371ea12 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/sync/mpsc/chan.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:8 | // 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 | 6871084629ad95c37c7136d865890ab2e371ea12 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/sync/mpsc/chan.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:9 | // AtomicWaker slot instead.
//
// This is not a spurious wakeup to `poll_recv` since we just got a
// Busy from `try_pop`, which only happens if there are messages in
// the queue.
self.inner.rx_waker.wake();
// Park the thread until the problema... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 6871084629ad95c37c7136d865890ab2e371ea12 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/sync/mpsc/chan.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:10 | fn send(&self, value: T) {
// Push the value
self.tx.push(value);
// Notify the rx task
self.rx_waker.wake();
}
}
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 being
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 6871084629ad95c37c7136d865890ab2e371ea12 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/sync/mpsc/chan.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:11 | self.semaphore.is_closed()
}
}
// ===== impl Semaphore for AtomicUsize =====
impl Semaphore for unbounded::Semaphore {
fn add_permit(&self) {
let prev = self.0.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 | 6871084629ad95c37c7136d865890ab2e371ea12 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/sync/mpsc/chan.rs | 401 | 428 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:9 | // AtomicWaker slot instead.
//
// This is not a spurious wakeup to `poll_recv` since we just got a
// Busy from `try_pop`, which only happens if there are messages in
// the queue.
self.inner.rx_waker.wake();
// Park the thread until the problema... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 707fb4d0df72d7ee6a4f4b5a675f84cd1863bc94 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/707fb4d0df72d7ee6a4f4b5a675f84cd1863bc94/tokio/src/sync/mpsc/chan.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:10 | fn send(&self, value: T) {
// Push the value
self.tx.push(value);
// Notify the rx task
self.rx_waker.wake();
}
}
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 being
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 707fb4d0df72d7ee6a4f4b5a675f84cd1863bc94 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/707fb4d0df72d7ee6a4f4b5a675f84cd1863bc94/tokio/src/sync/mpsc/chan.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:6 | inner: self.inner.clone(),
}
}
}
impl<T, S> Drop for Tx<T, S> {
fn drop(&mut self) {
if self.inner.tx_count.fetch_sub(1, AcqRel) != 1 {
return;
}
// Close the list, which sends a `Close` message
self.inner.tx.close();
// Notify the receiver
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 38d1bcd9df6af2de436c5f898829d071f8e46988 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/38d1bcd9df6af2de436c5f898829d071f8e46988/tokio/src/sync/mpsc/chan.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/sync/mpsc/chan.rs:7 | /// Receive the next value
pub(crate) fn recv(&mut self, cx: &mut Context<'_>) -> Poll<Option<T>> {
use super::block::Read::*;
ready!(crate::trace::trace_leaf(cx));
// Keep track of task budget
let coop = ready!(crate::runtime::coop::poll_proceed(cx));
self.inner.rx_fields... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/mpsc/chan.rs | MIT | 38d1bcd9df6af2de436c5f898829d071f8e46988 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/38d1bcd9df6af2de436c5f898829d071f8e46988/tokio/src/sync/mpsc/chan.rs | 241 | 300 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.