Trait stack_queue::BatchReducer
source · pub trait BatchReducer: Send + Sync + Sized + 'static {
type Task: Send + Sync + Sized + 'static;
}
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 = Accumulator::batch_reduce(9000, |range| {
Box::pin(async move { range.into_bounded().iter().sum::<usize>() })
}).await;