Consumer

Trait Consumer 

Source
pub trait Consumer<T> {
    // Required methods
    fn capacity(&self) -> usize;
    fn len(&self) -> usize;
    fn pop_many(&self, dst: &mut [MaybeUninit<T>]) -> usize;

    // Provided methods
    fn is_empty(&self) -> bool { ... }
    fn pop(&self) -> Option<T> { ... }
    fn steal_into(&self, dst: &impl SingleProducer<T>) -> usize { ... }
}
Expand description

A consumer of a queue.

Required Methods§

Source

fn capacity(&self) -> usize

Returns the capacity of the queue.

Source

fn len(&self) -> usize

Returns the length of the queue.

Source

fn pop_many(&self, dst: &mut [MaybeUninit<T>]) -> usize

Pops many values from the queue and returns the number of read values.

It may be non-lock-free.

Provided Methods§

Source

fn is_empty(&self) -> bool

Returns whether the queue is empty.

Source

fn pop(&self) -> Option<T>

Pops a value from the queue and returns it.

It may be non-lock-free.

Source

fn steal_into(&self, dst: &impl SingleProducer<T>) -> usize

Steals some values from the consumer and places them into dst. Returns the number of stolen values.

It requires that the other queue to be empty. Expected to steal the half of the queue, but other implementations may steal another number of values.

It may be non-lock-free.

§Panics

Panics if the other queue is not empty.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<T, const CAPACITY: usize, AtomicWrapper> Consumer<T> for MPMCBoundedQueue<T, CAPACITY, AtomicWrapper>
where AtomicWrapper: Deref<Target = LongAtomic> + Default,

Source§

impl<T: Send, SC> Consumer<T> for CachePaddedSPMCUnboundedConsumer<T, SC>
where SC: SyncCell<LightArc<Version<T>>>,

Source§

impl<T: Send, SC> Consumer<T> for SPMCUnboundedConsumer<T, SC>
where SC: SyncCell<LightArc<Version<T>>>,

Source§

impl<T: Send, SC> Consumer<T> for CachePaddedSPSCUnboundedConsumer<T, SC>
where SC: SyncCell<LightArc<Version<T>>>,

Source§

impl<T: Send, SC> Consumer<T> for SPSCUnboundedConsumer<T, SC>
where SC: SyncCell<LightArc<Version<T>>>,

Source§

impl<T: Send, const CAPACITY: usize> Consumer<T> for CachePaddedMPMCConsumer<T, CAPACITY>

Source§

impl<T: Send, const CAPACITY: usize> Consumer<T> for MPMCConsumer<T, CAPACITY>

Source§

impl<T: Send, const CAPACITY: usize> Consumer<T> for CachePaddedSPMCConsumer<T, CAPACITY>

Source§

impl<T: Send, const CAPACITY: usize> Consumer<T> for SPMCConsumer<T, CAPACITY>

Source§

impl<T: Send, const CAPACITY: usize> Consumer<T> for CachePaddedSPSCConsumer<T, CAPACITY>

Source§

impl<T: Send, const CAPACITY: usize> Consumer<T> for SPSCConsumer<T, CAPACITY>