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/broadcast.rs:20 | match (*ptr).waker {
Some(ref w) if w.will_wake(waker) => {}
_ => {
(*ptr).waker = Some(waker.clone());
}
}
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | 8efa62013b551d5130791c3a79ce8ab5cb0b5abf | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8efa62013b551d5130791c3a79ce8ab5cb0b5abf/tokio/src/sync/broadcast.rs | 761 | 820 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:21 | let missed = next.wrapping_sub(self.next);
drop(tail);
// The receiver is slow but no values have been missed
if missed == 0 {
self.next = self.next.wrapping_add(1);
return Ok(RecvGuard { slot });
}
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | 8efa62013b551d5130791c3a79ce8ab5cb0b5abf | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8efa62013b551d5130791c3a79ce8ab5cb0b5abf/tokio/src/sync/broadcast.rs | 801 | 860 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:24 | ///
/// # Examples
///
/// ```
/// use tokio::sync::broadcast;
///
/// #[tokio::main]
/// async fn main() {
/// let (tx, mut rx) = broadcast::channel(16);
///
/// assert!(rx.try_recv().is_err());
///
/// tx.send(10).unwrap();
///
/// let value = rx... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | 8efa62013b551d5130791c3a79ce8ab5cb0b5abf | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8efa62013b551d5130791c3a79ce8ab5cb0b5abf/tokio/src/sync/broadcast.rs | 921 | 980 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:25 | // Can't be empty
Err(TryRecvError::Empty) => panic!("unexpected empty broadcast channel"),
}
}
}
}
impl<R, T> Recv<R, T>
where
R: AsMut<Receiver<T>>,
{
fn new(receiver: R) -> Recv<R, T> {
Recv {
receiver,
waiter: UnsafeCell::new(Waiter {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | 8efa62013b551d5130791c3a79ce8ab5cb0b5abf | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8efa62013b551d5130791c3a79ce8ab5cb0b5abf/tokio/src/sync/broadcast.rs | 961 | 1,020 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:26 | T: Clone,
{
type Output = Result<T, RecvError>;
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<T, RecvError>> {
let (receiver, waiter) = self.project();
let guard = match receiver.recv_ref(Some((waiter, cx.waker()))) {
Ok(value) => value,
Err(TryRecv... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | 8efa62013b551d5130791c3a79ce8ab5cb0b5abf | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8efa62013b551d5130791c3a79ce8ab5cb0b5abf/tokio/src/sync/broadcast.rs | 1,001 | 1,060 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:27 | }
}
}
/// # Safety
///
/// `Waiter` is forced to be !Unpin.
unsafe impl linked_list::Link for Waiter {
type Handle = NonNull<Waiter>;
type Target = Waiter;
fn as_raw(handle: &NonNull<Waiter>) -> NonNull<Waiter> {
*handle
}
unsafe fn from_raw(ptr: NonNull<Waiter>) -> NonNull<Waiter> {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | 8efa62013b551d5130791c3a79ce8ab5cb0b5abf | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8efa62013b551d5130791c3a79ce8ab5cb0b5abf/tokio/src/sync/broadcast.rs | 1,041 | 1,096 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:28 | {
self.slot.val.with(|ptr| unsafe { (*ptr).clone() })
}
}
impl<'a, T> Drop for RecvGuard<'a, T> {
fn drop(&mut self) {
// Decrement the remaining counter
if 1 == self.slot.rem.fetch_sub(1, SeqCst) {
// Safety: Last receiver, drop the value
self.slot.val.with_mut(... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | 8efa62013b551d5130791c3a79ce8ab5cb0b5abf | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8efa62013b551d5130791c3a79ce8ab5cb0b5abf/tokio/src/sync/broadcast.rs | 1,081 | 1,096 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:25 | /// tx.send(i).unwrap();
/// }
/// });
///
/// // Streams must be pinned to iterate.
/// tokio::pin! {
/// let stream = rx
/// .into_stream()
/// .filter(Result::is_ok)
/// .map(Result::unwrap)
/// ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | 8bfb1c92ceadd04f847d98ed482e7e59a3074954 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8bfb1c92ceadd04f847d98ed482e7e59a3074954/tokio/src/sync/broadcast.rs | 961 | 1,020 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:26 | // Ignore lagging, we will catch up
Err(TryRecvError::Lagged(..)) => {}
// Can't be empty
Err(TryRecvError::Empty) => panic!("unexpected empty broadcast channel"),
}
}
}
}
impl<R, T> Recv<R, T>
where
R: AsMut<Receiver<T>>,
{
fn new(receive... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | 8bfb1c92ceadd04f847d98ed482e7e59a3074954 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8bfb1c92ceadd04f847d98ed482e7e59a3074954/tokio/src/sync/broadcast.rs | 1,001 | 1,060 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:27 | where
R: AsMut<Receiver<T>>,
T: Clone,
{
type Output = Result<T, RecvError>;
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<T, RecvError>> {
let (receiver, waiter) = self.project();
let guard = match receiver.recv_ref(Some((waiter, cx.waker()))) {
Ok(val... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | 8bfb1c92ceadd04f847d98ed482e7e59a3074954 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8bfb1c92ceadd04f847d98ed482e7e59a3074954/tokio/src/sync/broadcast.rs | 1,041 | 1,100 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:28 | Poll::Ready(guard.clone_value().map(Ok))
}
}
}
impl<R, T> Drop for Recv<R, T>
where
R: AsMut<Receiver<T>>,
{
fn drop(&mut self) {
// Acquire the tail lock. This is required for safety before accessing
// the waiter node.
let mut tail = self.receiver.as_mut().shared.tail.lock... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | 8bfb1c92ceadd04f847d98ed482e7e59a3074954 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8bfb1c92ceadd04f847d98ed482e7e59a3074954/tokio/src/sync/broadcast.rs | 1,081 | 1,140 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:29 | }
unsafe fn from_raw(ptr: NonNull<Waiter>) -> NonNull<Waiter> {
ptr
}
unsafe fn pointers(mut target: NonNull<Waiter>) -> NonNull<linked_list::Pointers<Waiter>> {
NonNull::from(&mut target.as_mut().pointers)
}
}
impl<T> fmt::Debug for Sender<T> {
fn fmt(&self, fmt: &mut fmt::Format... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | 8bfb1c92ceadd04f847d98ed482e7e59a3074954 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8bfb1c92ceadd04f847d98ed482e7e59a3074954/tokio/src/sync/broadcast.rs | 1,121 | 1,163 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:10 | }
/// Receive a value future
struct Recv<R, T>
where
R: AsMut<Receiver<T>>,
{
/// Receiver being waited on
receiver: R,
/// Entry in the waiter `LinkedList`
waiter: UnsafeCell<Waiter>,
_p: std::marker::PhantomData<T>,
}
/// `AsMut<T>` is not implemented for `T` (coherence). Explicitly implem... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | fb28caa90c8ab4453b259424c88dc7ec8ff06bbb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fb28caa90c8ab4453b259424c88dc7ec8ff06bbb/tokio/src/sync/broadcast.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:12 | ///
/// tx.send(10).unwrap();
/// tx.send(20).unwrap();
/// }
/// ```
pub fn channel<T: Clone>(mut capacity: usize) -> (Sender<T>, Receiver<T>) {
assert!(capacity > 0, "capacity is empty");
assert!(capacity <= usize::MAX >> 1, "requested capacity too large");
// Round to a power of two
capacity... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | fb28caa90c8ab4453b259424c88dc7ec8ff06bbb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fb28caa90c8ab4453b259424c88dc7ec8ff06bbb/tokio/src/sync/broadcast.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:16 | /// let (tx, _rx1) = broadcast::channel(16);
///
/// assert_eq!(1, tx.receiver_count());
///
/// let mut _rx2 = tx.subscribe();
///
/// assert_eq!(2, tx.receiver_count());
///
/// tx.send(10).unwrap();
/// }
/// ```
pub fn receiver_count(&self) -> usize {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | fb28caa90c8ab4453b259424c88dc7ec8ff06bbb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fb28caa90c8ab4453b259424c88dc7ec8ff06bbb/tokio/src/sync/broadcast.rs | 601 | 660 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:17 | // Set the closed bit if the value is `None`; otherwise write the value
if value.is_none() {
tail.closed = true;
slot.closed = true;
} else {
slot.val.with_mut(|ptr| unsafe { *ptr = value });
}
// Release the slot lock before notifying the receivers.
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | fb28caa90c8ab4453b259424c88dc7ec8ff06bbb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fb28caa90c8ab4453b259424c88dc7ec8ff06bbb/tokio/src/sync/broadcast.rs | 641 | 700 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:18 | while let Some(mut waiter) = self.waiters.pop_back() {
// Safety: `waiters` lock is still held.
let waiter = unsafe { waiter.as_mut() };
assert!(waiter.queued);
waiter.queued = false;
let waker = waiter.waker.take().unwrap();
waker.wake();
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | fb28caa90c8ab4453b259424c88dc7ec8ff06bbb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fb28caa90c8ab4453b259424c88dc7ec8ff06bbb/tokio/src/sync/broadcast.rs | 681 | 740 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:19 | if slot.pos != self.next {
let next_pos = slot.pos.wrapping_add(self.shared.buffer.len() as u64);
// The receiver has read all current values in the channel and there
// is no waiter to register
if waiter.is_none() && next_pos == self.next {
return Err(Tr... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | fb28caa90c8ab4453b259424c88dc7ec8ff06bbb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fb28caa90c8ab4453b259424c88dc7ec8ff06bbb/tokio/src/sync/broadcast.rs | 721 | 780 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:20 | // receipt of a new value.
match (*ptr).waker {
Some(ref w) if w.will_wake(waker) => {}
_ => {
(*ptr).waker = Some(waker.clone());
}
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | fb28caa90c8ab4453b259424c88dc7ec8ff06bbb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fb28caa90c8ab4453b259424c88dc7ec8ff06bbb/tokio/src/sync/broadcast.rs | 761 | 820 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:21 | let missed = next.wrapping_sub(self.next);
drop(tail);
// The receiver is slow but no values have been missed
if missed == 0 {
self.next = self.next.wrapping_add(1);
return Ok(RecvGuard { slot });
}
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | fb28caa90c8ab4453b259424c88dc7ec8ff06bbb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fb28caa90c8ab4453b259424c88dc7ec8ff06bbb/tokio/src/sync/broadcast.rs | 801 | 860 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:25 | /// for i in 0..10_i32 {
/// tx.send(i).unwrap();
/// }
/// });
///
/// // Streams must be pinned to iterate.
/// tokio::pin! {
/// let stream = rx
/// .into_stream()
/// .filter(Result::is_ok)
/// ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | fb28caa90c8ab4453b259424c88dc7ec8ff06bbb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fb28caa90c8ab4453b259424c88dc7ec8ff06bbb/tokio/src/sync/broadcast.rs | 961 | 1,020 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:26 | drop(tail);
while self.next != until {
match self.recv_ref(None) {
Ok(_) => {}
// The channel is closed
Err(TryRecvError::Closed) => break,
// Ignore lagging, we will catch up
Err(TryRecvError::Lagged(..)) => {}
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | fb28caa90c8ab4453b259424c88dc7ec8ff06bbb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fb28caa90c8ab4453b259424c88dc7ec8ff06bbb/tokio/src/sync/broadcast.rs | 1,001 | 1,060 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:27 | let me = self.get_unchecked_mut();
(me.receiver.as_mut(), &me.waiter)
}
}
}
impl<R, T> Future for Recv<R, T>
where
R: AsMut<Receiver<T>>,
T: Clone,
{
type Output = Result<T, RecvError>;
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<T, RecvError>> {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | fb28caa90c8ab4453b259424c88dc7ec8ff06bbb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fb28caa90c8ab4453b259424c88dc7ec8ff06bbb/tokio/src/sync/broadcast.rs | 1,041 | 1,100 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:28 | let guard = match receiver.recv_ref(Some((waiter, cx.waker()))) {
Ok(value) => value,
Err(TryRecvError::Empty) => return Poll::Pending,
Err(TryRecvError::Lagged(n)) => return Poll::Ready(Some(Err(RecvError::Lagged(n)))),
Err(TryRecvError::Closed) => return... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | fb28caa90c8ab4453b259424c88dc7ec8ff06bbb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fb28caa90c8ab4453b259424c88dc7ec8ff06bbb/tokio/src/sync/broadcast.rs | 1,081 | 1,140 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:29 | ///
/// `Waiter` is forced to be !Unpin.
unsafe impl linked_list::Link for Waiter {
type Handle = NonNull<Waiter>;
type Target = Waiter;
fn as_raw(handle: &NonNull<Waiter>) -> NonNull<Waiter> {
*handle
}
unsafe fn from_raw(ptr: NonNull<Waiter>) -> NonNull<Waiter> {
ptr
}
u... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | fb28caa90c8ab4453b259424c88dc7ec8ff06bbb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fb28caa90c8ab4453b259424c88dc7ec8ff06bbb/tokio/src/sync/broadcast.rs | 1,121 | 1,171 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:16 | /// [`Sender`]: crate::sync::broadcast::Sender
/// [`subscribe`]: crate::sync::broadcast::Sender::subscribe
/// [`channel`]: crate::sync::broadcast::channel
///
/// # Examples
///
/// ```
/// use tokio::sync::broadcast;
///
/// #[tokio::main]
/// async fn main() {
/// let... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | 2e05399f4b6be41680036cc158348973689840ca | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2e05399f4b6be41680036cc158348973689840ca/tokio/src/sync/broadcast.rs | 601 | 660 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:17 | tail.pos = tail.pos.wrapping_add(1);
// Get the slot
let mut slot = self.shared.buffer[idx].write().unwrap();
// Track the position
slot.pos = pos;
// Set remaining receivers
slot.rem.with_mut(|v| *v = rem);
// Set the closed bit if the value is `None`; otherw... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | 2e05399f4b6be41680036cc158348973689840ca | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2e05399f4b6be41680036cc158348973689840ca/tokio/src/sync/broadcast.rs | 641 | 700 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:18 | waiter.queued = false;
let waker = waiter.waker.take().unwrap();
waker.wake();
}
}
}
impl<T> Clone for Sender<T> {
fn clone(&self) -> Sender<T> {
let shared = self.shared.clone();
shared.num_tx.fetch_add(1, SeqCst);
Sender { shared }
}
}
impl<T> Dr... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | 2e05399f4b6be41680036cc158348973689840ca | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2e05399f4b6be41680036cc158348973689840ca/tokio/src/sync/broadcast.rs | 681 | 740 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:19 | // is no waiter to register
if waiter.is_none() && next_pos == self.next {
return Err(TryRecvError::Empty);
}
// Release the `slot` lock before attempting to acquire the `tail`
// lock. This is required because `send2` acquires the tail lock
/... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | 2e05399f4b6be41680036cc158348973689840ca | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2e05399f4b6be41680036cc158348973689840ca/tokio/src/sync/broadcast.rs | 721 | 780 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:20 | }
}
if !(*ptr).queued {
(*ptr).queued = true;
tail.waiters.push_front(NonNull::new_unchecked(&mut *ptr));
}
});
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | 2e05399f4b6be41680036cc158348973689840ca | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2e05399f4b6be41680036cc158348973689840ca/tokio/src/sync/broadcast.rs | 761 | 820 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:21 | // The receiver is slow but no values have been missed
if missed == 0 {
self.next = self.next.wrapping_add(1);
return Ok(RecvGuard { slot });
}
self.next = next;
return Err(TryRecvError::Lagged(missed));
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | 2e05399f4b6be41680036cc158348973689840ca | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2e05399f4b6be41680036cc158348973689840ca/tokio/src/sync/broadcast.rs | 801 | 860 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:25 | /// // Streams must be pinned to iterate.
/// tokio::pin! {
/// let stream = rx
/// .into_stream()
/// .filter(Result::is_ok)
/// .map(Result::unwrap)
/// .filter(|v| v % 2 == 0)
/// .map(|v| v + 1);
/// }
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | 2e05399f4b6be41680036cc158348973689840ca | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2e05399f4b6be41680036cc158348973689840ca/tokio/src/sync/broadcast.rs | 961 | 1,020 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:26 | }
}
}
}
impl<R, T> Recv<R, T>
where
R: AsMut<Receiver<T>>,
{
fn new(receiver: R) -> Recv<R, T> {
Recv {
receiver,
waiter: UnsafeCell::new(Waiter {
queued: false,
waker: None,
pointers: linked_list::Pointers::new(),
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | 2e05399f4b6be41680036cc158348973689840ca | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2e05399f4b6be41680036cc158348973689840ca/tokio/src/sync/broadcast.rs | 1,001 | 1,060 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:27 | type Output = Result<T, RecvError>;
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<T, RecvError>> {
let (receiver, waiter) = self.project();
let guard = match receiver.recv_ref(Some((waiter, cx.waker()))) {
Ok(value) => value,
Err(TryRecvError::Empty) =>... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | 2e05399f4b6be41680036cc158348973689840ca | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2e05399f4b6be41680036cc158348973689840ca/tokio/src/sync/broadcast.rs | 1,041 | 1,100 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:28 | impl<R, T> Drop for Recv<R, T>
where
R: AsMut<Receiver<T>>,
{
fn drop(&mut self) {
// Acquire the tail lock. This is required for safety before accessing
// the waiter node.
let mut tail = self.receiver.as_mut().shared.tail.lock();
// safety: tail lock is held
let queued... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | 2e05399f4b6be41680036cc158348973689840ca | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2e05399f4b6be41680036cc158348973689840ca/tokio/src/sync/broadcast.rs | 1,081 | 1,140 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:29 | }
unsafe fn pointers(mut target: NonNull<Waiter>) -> NonNull<linked_list::Pointers<Waiter>> {
NonNull::from(&mut target.as_mut().pointers)
}
}
impl<T> fmt::Debug for Sender<T> {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(fmt, "broadcast::Sender")
}
}
impl<T> f... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | 2e05399f4b6be41680036cc158348973689840ca | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2e05399f4b6be41680036cc158348973689840ca/tokio/src/sync/broadcast.rs | 1,121 | 1,159 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:6 | ///
/// A **send** operation can only fail if there are no active receivers,
/// implying that the message could never be received. The error contains the
/// message being sent as a payload so it can be recovered.
#[derive(Debug)]
pub struct SendError<T>(pub T);
/// An error returned from the [`recv`] function on a [... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | 242ea011891099f348b755b2ea10ec9e9ea104db | github | async-runtime | https://github.com/tokio-rs/tokio/blob/242ea011891099f348b755b2ea10ec9e9ea104db/tokio/src/sync/broadcast.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:7 | /// retained by the channel.
///
/// Includes the number of skipped messages.
Lagged(u64),
}
/// Data shared between senders and receivers
struct Shared<T> {
/// slots in the channel
buffer: Box<[RwLock<Slot<T>>]>,
/// Mask a position -> index
mask: usize,
/// Tail of the queue. Inclu... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | 242ea011891099f348b755b2ea10ec9e9ea104db | github | async-runtime | https://github.com/tokio-rs/tokio/blob/242ea011891099f348b755b2ea10ec9e9ea104db/tokio/src/sync/broadcast.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:8 | /// When this goes to zero, the value is released.
///
/// An atomic is used as it is mutated concurrently with the slot read lock
/// acquired.
rem: AtomicUsize,
/// Uniquely identifies the `send` stored in the slot
pos: u64,
/// True signals the channel is closed.
closed: bool,
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | 242ea011891099f348b755b2ea10ec9e9ea104db | github | async-runtime | https://github.com/tokio-rs/tokio/blob/242ea011891099f348b755b2ea10ec9e9ea104db/tokio/src/sync/broadcast.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:9 | where
R: AsMut<Receiver<T>>,
{
/// Receiver being waited on
receiver: R,
/// Entry in the waiter `LinkedList`
waiter: UnsafeCell<Waiter>,
_p: std::marker::PhantomData<T>,
}
/// `AsMut<T>` is not implemented for `T` (coherence). Explicitly implementing
/// `AsMut` for `Receiver` would be inclu... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | 242ea011891099f348b755b2ea10ec9e9ea104db | github | async-runtime | https://github.com/tokio-rs/tokio/blob/242ea011891099f348b755b2ea10ec9e9ea104db/tokio/src/sync/broadcast.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:10 | ///
/// The `Sender` can be cloned to `send` to the same channel from multiple
/// points in the process or it can be used concurrently from an `Arc`. New
/// `Receiver` handles are created by calling [`Sender::subscribe`].
///
/// If all [`Receiver`] handles are dropped, the `send` method will return a
/// [`SendError... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | 242ea011891099f348b755b2ea10ec9e9ea104db | github | async-runtime | https://github.com/tokio-rs/tokio/blob/242ea011891099f348b755b2ea10ec9e9ea104db/tokio/src/sync/broadcast.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:11 | pub fn channel<T: Clone>(mut capacity: usize) -> (Sender<T>, Receiver<T>) {
assert!(capacity > 0, "capacity is empty");
assert!(capacity <= usize::MAX >> 1, "requested capacity too large");
// Round to a power of two
capacity = capacity.next_power_of_two();
let mut buffer = Vec::with_capacity(capa... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | 242ea011891099f348b755b2ea10ec9e9ea104db | github | async-runtime | https://github.com/tokio-rs/tokio/blob/242ea011891099f348b755b2ea10ec9e9ea104db/tokio/src/sync/broadcast.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:13 | /// let (tx, mut rx1) = broadcast::channel(16);
/// let mut rx2 = tx.subscribe();
///
/// tokio::spawn(async move {
/// assert_eq!(rx1.recv().await.unwrap(), 10);
/// assert_eq!(rx1.recv().await.unwrap(), 20);
/// });
///
/// tokio::spawn(async move {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | 242ea011891099f348b755b2ea10ec9e9ea104db | github | async-runtime | https://github.com/tokio-rs/tokio/blob/242ea011891099f348b755b2ea10ec9e9ea104db/tokio/src/sync/broadcast.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:14 | ///
/// let value = rx.recv().await.unwrap();
/// assert_eq!(20, value);
/// }
/// ```
pub fn subscribe(&self) -> Receiver<T> {
let shared = self.shared.clone();
let mut tail = shared.tail.lock();
if tail.rx_cnt == MAX_RECEIVERS {
panic!("max receivers")... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | 242ea011891099f348b755b2ea10ec9e9ea104db | github | async-runtime | https://github.com/tokio-rs/tokio/blob/242ea011891099f348b755b2ea10ec9e9ea104db/tokio/src/sync/broadcast.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:15 | /// # Examples
///
/// ```
/// use tokio::sync::broadcast;
///
/// #[tokio::main]
/// async fn main() {
/// let (tx, _rx1) = broadcast::channel(16);
///
/// assert_eq!(1, tx.receiver_count());
///
/// let mut _rx2 = tx.subscribe();
///
/// assert_eq!(2... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | 242ea011891099f348b755b2ea10ec9e9ea104db | github | async-runtime | https://github.com/tokio-rs/tokio/blob/242ea011891099f348b755b2ea10ec9e9ea104db/tokio/src/sync/broadcast.rs | 561 | 620 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:16 | // Track the position
slot.pos = pos;
// Set remaining receivers
slot.rem.with_mut(|v| *v = rem);
// Set the closed bit if the value is `None`; otherwise write the value
if value.is_none() {
tail.closed = true;
slot.closed = true;
} else {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | 242ea011891099f348b755b2ea10ec9e9ea104db | github | async-runtime | https://github.com/tokio-rs/tokio/blob/242ea011891099f348b755b2ea10ec9e9ea104db/tokio/src/sync/broadcast.rs | 601 | 660 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:17 | }
}
}
impl<T> Clone for Sender<T> {
fn clone(&self) -> Sender<T> {
let shared = self.shared.clone();
shared.num_tx.fetch_add(1, SeqCst);
Sender { shared }
}
}
impl<T> Drop for Sender<T> {
fn drop(&mut self) {
if 1 == self.shared.num_tx.fetch_sub(1, SeqCst) {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | 242ea011891099f348b755b2ea10ec9e9ea104db | github | async-runtime | https://github.com/tokio-rs/tokio/blob/242ea011891099f348b755b2ea10ec9e9ea104db/tokio/src/sync/broadcast.rs | 641 | 700 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:18 | // Release the `slot` lock before attempting to acquire the `tail`
// lock. This is required because `send2` acquires the tail lock
// first followed by the slot lock. Acquiring the locks in reverse
// order here would result in a potential deadlock: `recv_ref`
// acquire... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | 242ea011891099f348b755b2ea10ec9e9ea104db | github | async-runtime | https://github.com/tokio-rs/tokio/blob/242ea011891099f348b755b2ea10ec9e9ea104db/tokio/src/sync/broadcast.rs | 681 | 740 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:19 | (*ptr).queued = true;
tail.waiters.push_front(NonNull::new_unchecked(&mut *ptr));
}
});
}
}
return Err(TryRecvError::Empty);
}
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | 242ea011891099f348b755b2ea10ec9e9ea104db | github | async-runtime | https://github.com/tokio-rs/tokio/blob/242ea011891099f348b755b2ea10ec9e9ea104db/tokio/src/sync/broadcast.rs | 721 | 780 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:20 | return Ok(RecvGuard { slot });
}
self.next = next;
return Err(TryRecvError::Lagged(missed));
}
}
self.next = self.next.wrapping_add(1);
if slot.closed {
return Err(TryRecvError::Closed);
}
Ok(RecvGuard {... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | 242ea011891099f348b755b2ea10ec9e9ea104db | github | async-runtime | https://github.com/tokio-rs/tokio/blob/242ea011891099f348b755b2ea10ec9e9ea104db/tokio/src/sync/broadcast.rs | 761 | 820 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:24 | /// .filter(Result::is_ok)
/// .map(Result::unwrap)
/// .filter(|v| v % 2 == 0)
/// .map(|v| v + 1);
/// }
///
/// while let Some(i) = stream.next().await {
/// println!("{}", i);
/// }
/// }
/// ```
#[cfg(fe... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | 242ea011891099f348b755b2ea10ec9e9ea104db | github | async-runtime | https://github.com/tokio-rs/tokio/blob/242ea011891099f348b755b2ea10ec9e9ea104db/tokio/src/sync/broadcast.rs | 921 | 980 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:25 | impl<R, T> Recv<R, T>
where
R: AsMut<Receiver<T>>,
{
fn new(receiver: R) -> Recv<R, T> {
Recv {
receiver,
waiter: UnsafeCell::new(Waiter {
queued: false,
waker: None,
pointers: linked_list::Pointers::new(),
_p: Phant... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | 242ea011891099f348b755b2ea10ec9e9ea104db | github | async-runtime | https://github.com/tokio-rs/tokio/blob/242ea011891099f348b755b2ea10ec9e9ea104db/tokio/src/sync/broadcast.rs | 961 | 1,020 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:26 | let guard = match receiver.recv_ref(Some((waiter, cx.waker()))) {
Ok(value) => value,
Err(TryRecvError::Empty) => return Poll::Pending,
Err(TryRecvError::Lagged(n)) => return Poll::Ready(Err(RecvError::Lagged(n))),
Err(TryRecvError::Closed) => return Poll::Ready(Err(RecvE... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | 242ea011891099f348b755b2ea10ec9e9ea104db | github | async-runtime | https://github.com/tokio-rs/tokio/blob/242ea011891099f348b755b2ea10ec9e9ea104db/tokio/src/sync/broadcast.rs | 1,001 | 1,060 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:27 | {
fn drop(&mut self) {
// Acquire the tail lock. This is required for safety before accessing
// the waiter node.
let mut tail = self.receiver.as_mut().shared.tail.lock();
// safety: tail lock is held
let queued = self.waiter.with(|ptr| unsafe { (*ptr).queued });
if... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | 242ea011891099f348b755b2ea10ec9e9ea104db | github | async-runtime | https://github.com/tokio-rs/tokio/blob/242ea011891099f348b755b2ea10ec9e9ea104db/tokio/src/sync/broadcast.rs | 1,041 | 1,100 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:28 | }
}
impl<T> fmt::Debug for Sender<T> {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(fmt, "broadcast::Sender")
}
}
impl<T> fmt::Debug for Receiver<T> {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(fmt, "broadcast::Receiver")
}
}
impl<'a, T>... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | 242ea011891099f348b755b2ea10ec9e9ea104db | github | async-runtime | https://github.com/tokio-rs/tokio/blob/242ea011891099f348b755b2ea10ec9e9ea104db/tokio/src/sync/broadcast.rs | 1,081 | 1,138 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:29 | }
}
impl std::error::Error for RecvError {}
impl fmt::Display for TryRecvError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
TryRecvError::Empty => write!(f, "channel empty"),
TryRecvError::Closed => write!(f, "channel closed"),
TryRecvError:... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | 242ea011891099f348b755b2ea10ec9e9ea104db | github | async-runtime | https://github.com/tokio-rs/tokio/blob/242ea011891099f348b755b2ea10ec9e9ea104db/tokio/src/sync/broadcast.rs | 1,121 | 1,138 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:6 | /// Error returned by [`Sender::send`][Sender::send].
///
/// A **send** operation can only fail if there are no active receivers,
/// implying that the message could never be received. The error contains the
/// message being sent as a payload so it can be recovered.
#[derive(Debug)]
pub struct SendError<T>(pub T);
/... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | 444660664b96f758610a0e7201a6a1a31a0f2405 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/444660664b96f758610a0e7201a6a1a31a0f2405/tokio/src/sync/broadcast.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:7 | /// The receiver lagged too far behind and has been forcibly disconnected.
/// Attempting to receive again will return the oldest message still
/// retained by the channel.
///
/// Includes the number of skipped messages.
Lagged(u64),
}
/// Data shared between senders and receivers
struct Shared<T>... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | 444660664b96f758610a0e7201a6a1a31a0f2405 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/444660664b96f758610a0e7201a6a1a31a0f2405/tokio/src/sync/broadcast.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:8 | /// Remaining number of receivers that are expected to see this value.
///
/// When this goes to zero, the value is released.
///
/// An atomic is used as it is mutated concurrently with the slot read lock
/// acquired.
rem: AtomicUsize,
/// Uniquely identifies the `send` stored in the slot... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | 444660664b96f758610a0e7201a6a1a31a0f2405 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/444660664b96f758610a0e7201a6a1a31a0f2405/tokio/src/sync/broadcast.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:9 | /// Receive a value future
struct Recv<R, T>
where
R: AsMut<Receiver<T>>,
{
/// Receiver being waited on
receiver: R,
/// Entry in the waiter `LinkedList`
waiter: UnsafeCell<Waiter>,
_p: std::marker::PhantomData<T>,
}
/// `AsMut<T>` is not implemented for `T` (coherence). Explicitly implement... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | 444660664b96f758610a0e7201a6a1a31a0f2405 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/444660664b96f758610a0e7201a6a1a31a0f2405/tokio/src/sync/broadcast.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:11 | /// }
/// ```
pub fn channel<T>(mut capacity: usize) -> (Sender<T>, Receiver<T>) {
assert!(capacity > 0, "capacity is empty");
assert!(capacity <= usize::MAX >> 1, "requested capacity too large");
// Round to a power of two
capacity = capacity.next_power_of_two();
let mut buffer = Vec::with_capaci... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | 444660664b96f758610a0e7201a6a1a31a0f2405 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/444660664b96f758610a0e7201a6a1a31a0f2405/tokio/src/sync/broadcast.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:14 | /// let mut rx = tx.subscribe();
///
/// tx.send(20).unwrap();
///
/// let value = rx.recv().await.unwrap();
/// assert_eq!(20, value);
/// }
/// ```
pub fn subscribe(&self) -> Receiver<T> {
let shared = self.shared.clone();
let mut tail = shared.tail.loc... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | 444660664b96f758610a0e7201a6a1a31a0f2405 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/444660664b96f758610a0e7201a6a1a31a0f2405/tokio/src/sync/broadcast.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:15 | ///
/// [`recv`]: crate::sync::broadcast::Receiver::recv
/// [`Receiver`]: crate::sync::broadcast::Receiver
/// [`Sender`]: crate::sync::broadcast::Sender
/// [`subscribe`]: crate::sync::broadcast::Sender::subscribe
/// [`channel`]: crate::sync::broadcast::channel
///
/// # Examples
///
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | 444660664b96f758610a0e7201a6a1a31a0f2405 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/444660664b96f758610a0e7201a6a1a31a0f2405/tokio/src/sync/broadcast.rs | 561 | 620 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:16 | let idx = (pos & self.shared.mask as u64) as usize;
// Update the tail position
tail.pos = tail.pos.wrapping_add(1);
// Get the slot
let mut slot = self.shared.buffer[idx].write().unwrap();
// Track the position
slot.pos = pos;
// Set remaining receivers
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | 444660664b96f758610a0e7201a6a1a31a0f2405 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/444660664b96f758610a0e7201a6a1a31a0f2405/tokio/src/sync/broadcast.rs | 601 | 660 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:17 | let waiter = unsafe { waiter.as_mut() };
assert!(waiter.queued);
waiter.queued = false;
let waker = waiter.waker.take().unwrap();
waker.wake();
}
}
}
impl<T> Clone for Sender<T> {
fn clone(&self) -> Sender<T> {
let shared = self.shared.clone();
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | 444660664b96f758610a0e7201a6a1a31a0f2405 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/444660664b96f758610a0e7201a6a1a31a0f2405/tokio/src/sync/broadcast.rs | 641 | 700 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:18 | let next_pos = slot.pos.wrapping_add(self.shared.buffer.len() as u64);
// The receiver has read all current values in the channel and there
// is no waiter to register
if waiter.is_none() && next_pos == self.next {
return Err(TryRecvError::Empty);
}
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | 444660664b96f758610a0e7201a6a1a31a0f2405 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/444660664b96f758610a0e7201a6a1a31a0f2405/tokio/src/sync/broadcast.rs | 681 | 740 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:19 | Some(ref w) if w.will_wake(waker) => {}
_ => {
(*ptr).waker = Some(waker.clone());
}
}
if !(*ptr).queued {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | 444660664b96f758610a0e7201a6a1a31a0f2405 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/444660664b96f758610a0e7201a6a1a31a0f2405/tokio/src/sync/broadcast.rs | 721 | 780 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:20 | drop(tail);
// The receiver is slow but no values have been missed
if missed == 0 {
self.next = self.next.wrapping_add(1);
return Ok(RecvGuard { slot });
}
self.next = next;
return Err(TryRecvErro... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | 444660664b96f758610a0e7201a6a1a31a0f2405 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/444660664b96f758610a0e7201a6a1a31a0f2405/tokio/src/sync/broadcast.rs | 761 | 820 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:21 | ///
/// If the [`Receiver`] handle falls behind, once the channel is full, newly
/// sent values will overwrite old values. At this point, a call to [`recv`]
/// will return with `Err(TryRecvError::Lagged)` and the [`Receiver`]'s
/// internal cursor is updated to point to the oldest value still held by
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | 444660664b96f758610a0e7201a6a1a31a0f2405 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/444660664b96f758610a0e7201a6a1a31a0f2405/tokio/src/sync/broadcast.rs | 801 | 860 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:22 | // The borrow checker prohibits calling `self.poll_ref` while passing in
// a mutable ref to a field (as it should). To work around this,
// `waiter` is first *removed* from `self` then `poll_recv` is called.
//
// However, for safety, we must ensure that `waiter` is **not** dropped.
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | 444660664b96f758610a0e7201a6a1a31a0f2405 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/444660664b96f758610a0e7201a6a1a31a0f2405/tokio/src/sync/broadcast.rs | 841 | 900 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:24 | /// tokio::spawn(async move {
/// assert_eq!(rx2.recv().await.unwrap(), 10);
/// assert_eq!(rx2.recv().await.unwrap(), 20);
/// });
///
/// tx.send(10).unwrap();
/// tx.send(20).unwrap();
/// }
/// ```
///
/// Handling lag
///
/// ```
/... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | 444660664b96f758610a0e7201a6a1a31a0f2405 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/444660664b96f758610a0e7201a6a1a31a0f2405/tokio/src/sync/broadcast.rs | 921 | 980 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:25 | impl<T> crate::stream::Stream for Receiver<T>
where
T: Clone,
{
type Item = Result<T, RecvError>;
fn poll_next(
mut self: std::pin::Pin<&mut Self>,
cx: &mut Context<'_>,
) -> Poll<Option<Result<T, RecvError>>> {
#[allow(deprecated)]
self.poll_recv(cx).map(|v| match v {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | 444660664b96f758610a0e7201a6a1a31a0f2405 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/444660664b96f758610a0e7201a6a1a31a0f2405/tokio/src/sync/broadcast.rs | 961 | 1,020 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:26 | tail.rx_cnt -= 1;
let until = tail.pos;
drop(tail);
while self.next != until {
match self.recv_ref(None) {
Ok(_) => {}
// The channel is closed
Err(TryRecvError::Closed) => break,
// Ignore lagging, we will catch up
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | 444660664b96f758610a0e7201a6a1a31a0f2405 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/444660664b96f758610a0e7201a6a1a31a0f2405/tokio/src/sync/broadcast.rs | 1,001 | 1,060 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:27 | // Safety: Receiver is Unpin
is_unpin::<&mut Receiver<T>>();
let me = self.get_unchecked_mut();
(me.receiver.as_mut(), &me.waiter)
}
}
}
impl<R, T> Future for Recv<R, T>
where
R: AsMut<Receiver<T>>,
T: Clone,
{
type Output = Result<T, RecvError>;
fn pol... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | 444660664b96f758610a0e7201a6a1a31a0f2405 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/444660664b96f758610a0e7201a6a1a31a0f2405/tokio/src/sync/broadcast.rs | 1,041 | 1,100 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:28 | ///
/// ```
/// use tokio::stream::StreamExt;
/// use tokio::sync::broadcast;
///
/// #[tokio::main]
/// async fn main() {
/// let (tx, rx) = broadcast::channel(128);
///
/// tokio::spawn(async move {
/// for i in 0..10_i32 ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | 444660664b96f758610a0e7201a6a1a31a0f2405 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/444660664b96f758610a0e7201a6a1a31a0f2405/tokio/src/sync/broadcast.rs | 1,081 | 1,140 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:29 | type Item = Result<T, RecvError>;
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
let (receiver, waiter) = self.project();
let guard = match receiver.recv_ref(Some((waiter, cx.waker()))) {
Ok(value) => value,
Err(Tr... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | 444660664b96f758610a0e7201a6a1a31a0f2405 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/444660664b96f758610a0e7201a6a1a31a0f2405/tokio/src/sync/broadcast.rs | 1,121 | 1,180 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:30 | }
}
/// # Safety
///
/// `Waiter` is forced to be !Unpin.
unsafe impl linked_list::Link for Waiter {
type Handle = NonNull<Waiter>;
type Target = Waiter;
fn as_raw(handle: &NonNull<Waiter>) -> NonNull<Waiter> {
*handle
}
unsafe fn from_raw(ptr: NonNull<Waiter>) -> NonNull<Waiter> {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | 444660664b96f758610a0e7201a6a1a31a0f2405 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/444660664b96f758610a0e7201a6a1a31a0f2405/tokio/src/sync/broadcast.rs | 1,161 | 1,220 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:31 | self.slot.val.with(|ptr| unsafe { (*ptr).clone() })
}
}
impl<'a, T> Drop for RecvGuard<'a, T> {
fn drop(&mut self) {
// Decrement the remaining counter
if 1 == self.slot.rem.fetch_sub(1, SeqCst) {
// Safety: Last receiver, drop the value
self.slot.val.with_mut(|ptr| unsa... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | 444660664b96f758610a0e7201a6a1a31a0f2405 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/444660664b96f758610a0e7201a6a1a31a0f2405/tokio/src/sync/broadcast.rs | 1,201 | 1,238 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:14 | /// let mut rx = tx.subscribe();
///
/// tx.send(20).unwrap();
///
/// let value = rx.recv().await.unwrap();
/// assert_eq!(20, value);
/// }
/// ```
pub fn subscribe(&self) -> Receiver<T> {
let shared = self.shared.clone();
let mut tail = shared.tail.loc... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | 3fd043931e6d37f211e682980edc6e12e9d4fc54 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3fd043931e6d37f211e682980edc6e12e9d4fc54/tokio/src/sync/broadcast.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:15 | ///
/// [`recv`]: crate::sync::broadcast::Receiver::recv
/// [`Receiver`]: crate::sync::broadcast::Receiver
/// [`Sender`]: crate::sync::broadcast::Sender
/// [`subscribe`]: crate::sync::broadcast::Sender::subscribe
/// [`channel`]: crate::sync::broadcast::channel
///
/// # Examples
///
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | 3fd043931e6d37f211e682980edc6e12e9d4fc54 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3fd043931e6d37f211e682980edc6e12e9d4fc54/tokio/src/sync/broadcast.rs | 561 | 620 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:17 | let waiter = unsafe { waiter.as_mut() };
assert!(waiter.queued);
waiter.queued = false;
let waker = waiter.waker.take().unwrap();
waker.wake();
}
}
}
impl<T> Clone for Sender<T> {
fn clone(&self) -> Sender<T> {
let shared = self.shared.clone();
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | 3fd043931e6d37f211e682980edc6e12e9d4fc54 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3fd043931e6d37f211e682980edc6e12e9d4fc54/tokio/src/sync/broadcast.rs | 641 | 700 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:18 | let next_pos = slot.pos.wrapping_add(self.shared.buffer.len() as u64);
// The receiver has read all current values in the channel and there
// is no waiter to register
if waiter.is_none() && next_pos == self.next {
return Err(TryRecvError::Empty);
}
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | 3fd043931e6d37f211e682980edc6e12e9d4fc54 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3fd043931e6d37f211e682980edc6e12e9d4fc54/tokio/src/sync/broadcast.rs | 681 | 740 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:25 | impl<T> crate::stream::Stream for Receiver<T>
where
T: Clone,
{
type Item = Result<T, RecvError>;
fn poll_next(
mut self: std::pin::Pin<&mut Self>,
cx: &mut Context<'_>,
) -> Poll<Option<Result<T, RecvError>>> {
#[allow(deprecated)]
self.poll_recv(cx).map(|v| match v {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | 3fd043931e6d37f211e682980edc6e12e9d4fc54 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3fd043931e6d37f211e682980edc6e12e9d4fc54/tokio/src/sync/broadcast.rs | 961 | 1,020 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:29 | type Item = Result<T, RecvError>;
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
let (receiver, waiter) = self.project();
let guard = match receiver.recv_ref(Some((waiter, cx.waker()))) {
Ok(value) => value,
Err(Tr... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | 3fd043931e6d37f211e682980edc6e12e9d4fc54 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3fd043931e6d37f211e682980edc6e12e9d4fc54/tokio/src/sync/broadcast.rs | 1,121 | 1,180 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:20 | drop(tail);
// The receiver is slow but no values have been missed
if missed == 0 {
self.next = self.next.wrapping_add(1);
return Ok(RecvGuard { slot });
}
self.next = next;
return Err(TryRecvErro... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | c9f5bc29158a6f3a786e9d67df8da31524e8a9c3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c9f5bc29158a6f3a786e9d67df8da31524e8a9c3/tokio/src/sync/broadcast.rs | 761 | 820 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:7 | /// The receiver lagged too far behind and has been forcibly disconnected.
/// Attempting to receive again will return the oldest message still
/// retained by the channel.
///
/// Includes the number of skipped messages.
Lagged(u64),
}
/// Data shared between senders and receivers
struct Shared<T>... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | 9f0b6d316694e88bfd0637f166ffc177789176b2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9f0b6d316694e88bfd0637f166ffc177789176b2/tokio/src/sync/broadcast.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:20 | drop(tail);
// The receiver is slow but no values have been missed
if missed == 0 {
self.next = self.next.wrapping_add(1);
return Ok(RecvGuard { slot });
}
self.next = next;
return Err(TryRecvErro... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | fb7dfcf4322b5e60604815aea91266b88f0b7823 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fb7dfcf4322b5e60604815aea91266b88f0b7823/tokio/src/sync/broadcast.rs | 761 | 820 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:21 | ///
/// If the [`Receiver`] handle falls behind, once the channel is full, newly
/// sent values will overwrite old values. At this point, a call to [`recv`]
/// will return with `Err(TryRecvError::Lagged)` and the [`Receiver`]'s
/// internal cursor is updated to point to the oldest value still held by
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | fb7dfcf4322b5e60604815aea91266b88f0b7823 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fb7dfcf4322b5e60604815aea91266b88f0b7823/tokio/src/sync/broadcast.rs | 801 | 860 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:22 | // a mutable ref to a field (as it should). To work around this,
// `waiter` is first *removed* from `self` then `poll_recv` is called.
//
// However, for safety, we must ensure that `waiter` is **not** dropped.
// It could be contained in the intrusive linked list. The `Receiver`
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | fb7dfcf4322b5e60604815aea91266b88f0b7823 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fb7dfcf4322b5e60604815aea91266b88f0b7823/tokio/src/sync/broadcast.rs | 841 | 900 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:24 | /// assert_eq!(rx2.recv().await.unwrap(), 10);
/// assert_eq!(rx2.recv().await.unwrap(), 20);
/// });
///
/// tx.send(10).unwrap();
/// tx.send(20).unwrap();
/// }
/// ```
///
/// Handling lag
///
/// ```
/// use tokio::sync::broadcast;
///... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | fb7dfcf4322b5e60604815aea91266b88f0b7823 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fb7dfcf4322b5e60604815aea91266b88f0b7823/tokio/src/sync/broadcast.rs | 921 | 980 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:25 | where
T: Clone,
{
type Item = Result<T, RecvError>;
fn poll_next(
mut self: std::pin::Pin<&mut Self>,
cx: &mut Context<'_>,
) -> Poll<Option<Result<T, RecvError>>> {
#[allow(deprecated)]
self.poll_recv(cx).map(|v| match v {
Ok(v) => Some(Ok(v)),
l... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | fb7dfcf4322b5e60604815aea91266b88f0b7823 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fb7dfcf4322b5e60604815aea91266b88f0b7823/tokio/src/sync/broadcast.rs | 961 | 1,020 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:26 | let until = tail.pos;
drop(tail);
while self.next != until {
match self.recv_ref(None) {
Ok(_) => {}
// The channel is closed
Err(TryRecvError::Closed) => break,
// Ignore lagging, we will catch up
Err(TryRecvE... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | fb7dfcf4322b5e60604815aea91266b88f0b7823 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fb7dfcf4322b5e60604815aea91266b88f0b7823/tokio/src/sync/broadcast.rs | 1,001 | 1,060 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:27 | is_unpin::<&mut Receiver<T>>();
let me = self.get_unchecked_mut();
(me.receiver.as_mut(), &me.waiter)
}
}
}
impl<R, T> Future for Recv<R, T>
where
R: AsMut<Receiver<T>>,
T: Clone,
{
type Output = Result<T, RecvError>;
fn poll(self: Pin<&mut Self>, cx: &mut Context<... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | fb7dfcf4322b5e60604815aea91266b88f0b7823 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fb7dfcf4322b5e60604815aea91266b88f0b7823/tokio/src/sync/broadcast.rs | 1,041 | 1,100 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:28 | /// ```
/// use tokio::stream::StreamExt;
/// use tokio::sync::broadcast;
///
/// #[tokio::main]
/// async fn main() {
/// let (tx, rx) = broadcast::channel(128);
///
/// tokio::spawn(async move {
/// for i in 0..10_i32 {
//... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | fb7dfcf4322b5e60604815aea91266b88f0b7823 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fb7dfcf4322b5e60604815aea91266b88f0b7823/tokio/src/sync/broadcast.rs | 1,081 | 1,140 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:29 | fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
let (receiver, waiter) = self.project();
let guard = match receiver.recv_ref(Some((waiter, cx.waker()))) {
Ok(value) => value,
Err(TryRecvError::Empty) => return Poll::Pending,... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | fb7dfcf4322b5e60604815aea91266b88f0b7823 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fb7dfcf4322b5e60604815aea91266b88f0b7823/tokio/src/sync/broadcast.rs | 1,121 | 1,180 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:30 | }
/// # Safety
///
/// `Waiter` is forced to be !Unpin.
unsafe impl linked_list::Link for Waiter {
type Handle = NonNull<Waiter>;
type Target = Waiter;
fn as_raw(handle: &NonNull<Waiter>) -> NonNull<Waiter> {
*handle
}
unsafe fn from_raw(ptr: NonNull<Waiter>) -> NonNull<Waiter> {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | fb7dfcf4322b5e60604815aea91266b88f0b7823 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fb7dfcf4322b5e60604815aea91266b88f0b7823/tokio/src/sync/broadcast.rs | 1,161 | 1,220 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:31 | }
}
impl<'a, T> Drop for RecvGuard<'a, T> {
fn drop(&mut self) {
// Decrement the remaining counter
if 1 == self.slot.rem.fetch_sub(1, SeqCst) {
// Safety: Last receiver, drop the value
self.slot.val.with_mut(|ptr| unsafe { *ptr = None });
}
}
}
impl fmt::Displa... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | fb7dfcf4322b5e60604815aea91266b88f0b7823 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fb7dfcf4322b5e60604815aea91266b88f0b7823/tokio/src/sync/broadcast.rs | 1,201 | 1,237 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:6 | /// A **send** operation can only fail if there are no active receivers,
/// implying that the message could never be received. The error contains the
/// message being sent as a payload so it can be recovered.
#[derive(Debug)]
pub struct SendError<T>(pub T);
/// An error returned from the [`recv`] function on a [`Rec... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | cc8a6625982b5fc0694d05b4e9fb7d6a592702a1 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cc8a6625982b5fc0694d05b4e9fb7d6a592702a1/tokio/src/sync/broadcast.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:7 | ///
/// Includes the number of skipped messages.
Lagged(u64),
}
/// Data shared between senders and receivers
struct Shared<T> {
/// slots in the channel
buffer: Box<[RwLock<Slot<T>>]>,
/// Mask a position -> index
mask: usize,
/// Tail of the queue
tail: Mutex<Tail>,
/// Stack o... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | cc8a6625982b5fc0694d05b4e9fb7d6a592702a1 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cc8a6625982b5fc0694d05b4e9fb7d6a592702a1/tokio/src/sync/broadcast.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/sync/broadcast.rs:8 | ///
/// An atomic is used as it is mutated concurrently with the slot read lock
/// acquired.
rem: AtomicUsize,
/// Uniquely identifies the `send` stored in the slot
pos: u64,
/// True signals the channel is closed.
closed: bool,
/// The value being broadcast.
///
/// The valu... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/broadcast.rs | MIT | cc8a6625982b5fc0694d05b4e9fb7d6a592702a1 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cc8a6625982b5fc0694d05b4e9fb7d6a592702a1/tokio/src/sync/broadcast.rs | 281 | 340 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.