pub trait BatchReducer: Send + Sync + Sized + 'static {
    type Task: Send + Sync + Sized + 'static;

    // Provided methods
    fn batch_reduce<'a, const N: usize, F, R>(
        task: Self::Task,
        reducer: F
    ) -> BatchReduce<'a, Self, F, R, N> 
       where Self: LocalQueue<N, BufferCell = BufferCell<Self::Task>>,
             F: for<'b> FnOnce(BufferIter<'b, Self::Task, N>) -> R + Send { ... }
    fn batch_collect<'a, const N: usize>(
        task: Self::Task
    ) -> BatchCollect<'a, Self, N> 
       where Self: LocalQueue<N, BufferCell = BufferCell<Self::Task>> { ... }
}
Expand description

Auto-batched queue whereby tasks are reduced or collected

Example

struct Accumulator;

#[local_queue]
impl BatchReducer for Accumulator {
  type Task = usize;
}

let sum: Option<usize> = Accumulator::batch_reduce(9000, |batch| batch.sum::<usize>()).await;

Required Associated Types§

source

type Task: Send + Sync + Sized + 'static

Provided Methods§

source

fn batch_reduce<'a, const N: usize, F, R>( task: Self::Task, reducer: F ) -> BatchReduce<'a, Self, F, R, N> where Self: LocalQueue<N, BufferCell = BufferCell<Self::Task>>, F: for<'b> FnOnce(BufferIter<'b, Self::Task, N>) -> R + Send,

Reduce over tasks batched in an async context

source

fn batch_collect<'a, const N: usize>( task: Self::Task ) -> BatchCollect<'a, Self, N> where Self: LocalQueue<N, BufferCell = BufferCell<Self::Task>>,

Collect tasks batched in an async context

Implementors§