Skip to main content

BatchSource

Trait BatchSource 

Source
pub trait BatchSource {
    type Item;

    // Required methods
    fn drain_batch(&self, out: &mut [Self::Item]) -> usize;
    fn len(&self) -> usize;

    // Provided method
    fn is_empty(&self) -> bool { ... }
}
Expand description

A source drained in owned batches through a shared &self, so multiple consumers may pull disjoint batches concurrently.

Required Associated Types§

Source

type Item

The owned item pulled from the source.

Required Methods§

Source

fn drain_batch(&self, out: &mut [Self::Item]) -> usize

Pull up to out.len() items FIFO into out, returning the count filled. Safe to call from several threads at once — each caller gets a disjoint batch (the impl linearises the dequeue).

Source

fn len(&self) -> usize

A snapshot lower bound on the items available (a racing producer just defers to the next pull). Consumers size their scratch buffer from it.

Provided Methods§

Source

fn is_empty(&self) -> bool

True when the snapshot shows nothing to pull.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<R: RingStorage> BatchSource for BoundedQueue<R>

Source§

type Item = <R as RingStorage>::Item

Source§

fn drain_batch(&self, out: &mut [R::Item]) -> usize

Source§

fn len(&self) -> usize

Implementors§