LockFreeConsumer

Trait LockFreeConsumer 

Source
pub trait LockFreeConsumer<T>: Consumer<T> {
    // Required method
    fn lock_free_pop_many(&self, dst: &mut [MaybeUninit<T>]) -> (usize, bool);

    // Provided methods
    fn lock_free_pop(&self) -> Result<T, LockFreePopErr> { ... }
    fn lock_free_steal_into(
        &self,
        dst: &impl SingleLockFreeProducer<T>,
    ) -> (usize, bool) { ... }
}
Expand description

A lock-free consumer of a queue.

Required Methods§

Source

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

Pops many values from the queue. Returns the number of popped values and whether the operation failed because it should wait.

It is lock-free. If you can lock, you can look at the Consumer::pop_many method because if it is implemented not as lock-free, it should have better performance.

Provided Methods§

Source

fn lock_free_pop(&self) -> Result<T, LockFreePopErr>

Pops a value from the queue. On failure, returns Err(LockFreePopErr).

It is lock-free. If you can lock, you can look at the Consumer::pop method because if it is implemented not as lock-free, it should have better performance.

Source

fn lock_free_steal_into( &self, dst: &impl SingleLockFreeProducer<T>, ) -> (usize, bool)

Steals some values from the consumer and places them into dst. Returns the number of stolen values and whether the operation failed because it should wait.

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 is lock-free. If you can lock, you can look at the Consumer::steal_into method because if it is implemented not as lock-free, it should have better performance.

§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> LockFreeConsumer<T> for MPMCBoundedQueue<T, CAPACITY, AtomicWrapper>
where AtomicWrapper: Deref<Target = LongAtomic> + Default,

Source§

impl<T: Send, SC> LockFreeConsumer<T> for CachePaddedSPMCUnboundedConsumer<T, SC>

Source§

impl<T: Send, SC> LockFreeConsumer<T> for SPMCUnboundedConsumer<T, SC>

Source§

impl<T: Send, SC> LockFreeConsumer<T> for CachePaddedSPSCUnboundedConsumer<T, SC>

Source§

impl<T: Send, SC> LockFreeConsumer<T> for SPSCUnboundedConsumer<T, SC>

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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