Trait stack_queue::BatchReducer 
source · pub trait BatchReducer: Send + Sync + Sized + 'static {
    type Task: Send + Sync + Sized + 'static;
    type impl_trait_batch_reduce_0<'async_trait, const N: usize, F, R: 'async_trait>: Future<Output = Option<R>> + 'async_trait + Send
       where Self: LocalQueue<N, BufferCell = BufferCell<Self::Task>>,
             F: for<'a> FnOnce(UnboundedRange<'a, Self::Task, N>) -> Pin<Box<dyn Future<Output = R> + Send + 'a>> + Send + 'async_trait;
    // Required method
    fn batch_reduce<'async_trait, const N: usize, F, R: 'async_trait>(
        task: Self::Task,
        f: F
    ) -> Self::impl_trait_batch_reduce_0<'async_trait, N, F, R>
       where Self: LocalQueue<N, BufferCell = BufferCell<Self::Task>>,
             F: for<'a> FnOnce(UnboundedRange<'a, Self::Task, N>) -> Pin<Box<dyn Future<Output = R> + Send + 'a>> + Send + 'async_trait;
}Expand description
Auto-batched queue whereby batches are reduced by a closure
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;Required Associated Types§
type Task: Send + Sync + Sized + 'static
type impl_trait_batch_reduce_0<'async_trait, const N: usize, F, R: 'async_trait>: Future<Output = Option<R>> + 'async_trait + Send where Self: LocalQueue<N, BufferCell = BufferCell<Self::Task>>, F: for<'a> FnOnce(UnboundedRange<'a, Self::Task, N>) -> Pin<Box<dyn Future<Output = R> + Send + 'a>> + Send + 'async_trait
Required Methods§
sourcefn batch_reduce<'async_trait, const N: usize, F, R: 'async_trait>(
    task: Self::Task,
    f: F
) -> Self::impl_trait_batch_reduce_0<'async_trait, N, F, R>where
    Self: LocalQueue<N, BufferCell = BufferCell<Self::Task>>,
    F: for<'a> FnOnce(UnboundedRange<'a, Self::Task, N>) -> Pin<Box<dyn Future<Output = R> + Send + 'a>> + Send + 'async_trait,
 
fn batch_reduce<'async_trait, const N: usize, F, R: 'async_trait>( task: Self::Task, f: F ) -> Self::impl_trait_batch_reduce_0<'async_trait, N, F, R>where Self: LocalQueue<N, BufferCell = BufferCell<Self::Task>>, F: for<'a> FnOnce(UnboundedRange<'a, Self::Task, N>) -> Pin<Box<dyn Future<Output = R> + Send + 'a>> + Send + 'async_trait,
Enqueue and auto-batch task, using reducer fn once per batch. The local_queue macro will implement batch_reduce