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§
Provided Methods§
Sourcefn 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_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
Sourcefn batch_collect<'a, const N: usize>(
task: Self::Task,
) -> BatchCollect<'a, Self, N> ⓘwhere
Self: LocalQueue<N, BufferCell = BufferCell<Self::Task>>,
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
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.