BlockingMpscReceiver

Struct BlockingMpscReceiver 

Source
pub struct BlockingMpscReceiver<T, const P: usize, const NUM_SEGS_P2: usize> { /* private fields */ }
Expand description

Blocking MPSC receiver.

The blocking receiver can work with both async and blocking senders.

Implementations§

Source§

impl<T, const P: usize, const NUM_SEGS_P2: usize> BlockingMpscReceiver<T, P, NUM_SEGS_P2>

Source

pub fn try_recv(&mut self) -> Result<T, PopError>

Source

pub fn recv(&mut self) -> Result<T, PopError>

Blocking receive that parks the thread until an item is available.

Source

pub fn recv_batch(&mut self, dst: &mut [T]) -> Result<usize, PopError>

Receives multiple items into a destination slice, blocking until at least one arrives.

This method fills the provided slice with items from the queue, blocking the thread until at least one item is available. It returns as soon as any items are received (partial fill) or when the queue is closed.

§Advantages over recv() in a loop
  • Bulk operations: More efficient than calling recv() repeatedly
  • Partial results: Returns immediately with whatever is available
  • Reduced overhead: Fewer waker registrations and context switches
  • Automatic backpressure: Notifies producers as space becomes available
§Returns
  • Ok(count): Number of items written to dst (1..=dst.len())
  • Err(PopError::Closed): Queue closed with no items available
§Example
let mut buffer = [0u32; 128];
match receiver.recv_batch(&mut buffer) {
    Ok(count) => {
        // Process buffer[..count]
    }
    Err(PopError::Closed) => {
        // Queue closed
    }
}

Auto Trait Implementations§

§

impl<T, const P: usize, const NUM_SEGS_P2: usize> Freeze for BlockingMpscReceiver<T, P, NUM_SEGS_P2>

§

impl<T, const P: usize, const NUM_SEGS_P2: usize> !RefUnwindSafe for BlockingMpscReceiver<T, P, NUM_SEGS_P2>

§

impl<T, const P: usize, const NUM_SEGS_P2: usize> Send for BlockingMpscReceiver<T, P, NUM_SEGS_P2>

§

impl<T, const P: usize, const NUM_SEGS_P2: usize> Sync for BlockingMpscReceiver<T, P, NUM_SEGS_P2>

§

impl<T, const P: usize, const NUM_SEGS_P2: usize> Unpin for BlockingMpscReceiver<T, P, NUM_SEGS_P2>

§

impl<T, const P: usize, const NUM_SEGS_P2: usize> !UnwindSafe for BlockingMpscReceiver<T, P, NUM_SEGS_P2>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V