pub struct Batches<'scope, S: Strategy> { /* private fields */ }Expand description
Batches supplied for one invocation of Strategy::run_batches.
Consume this value to prepare and execute the batches. Preparation can borrow input slices or split mutable output buffers into disjoint slices for each batch. A whole-input run supplies one batch that executes on the calling thread.
Batches cannot outlive the operation that receives them:
use commonware_parallel::{Sequential, Strategy};
use core::num::NonZeroUsize;
let batches = Sequential.run_batches(8, NonZeroUsize::MIN, 1, |batches| batches);Implementations§
Source§impl<'scope, S: Strategy> Batches<'scope, S>
impl<'scope, S: Strategy> Batches<'scope, S>
Sourcepub const fn is_whole(&self) -> bool
pub const fn is_whole(&self) -> bool
Returns whether the strategy supplied the whole input as one batch, which executes on the calling thread.
Such a run can process the input directly rather than preparing its single batch.
Sourcepub fn map_collect_vec<I, P, F, R>(self, prepare: P, map_op: F) -> Vec<R>
pub fn map_collect_vec<I, P, F, R>(self, prepare: P, map_op: F) -> Vec<R>
Prepare and map batches, collecting results in batch order.
prepare receives ordered ranges that partition the input and must return one item per
range in the same order. map_op may run those items in any order.
Sourcepub fn try_map_collect_vec<I, P, F, R, E>(
self,
prepare: P,
map_op: F,
) -> Result<Vec<R>, E>
pub fn try_map_collect_vec<I, P, F, R, E>( self, prepare: P, map_op: F, ) -> Result<Vec<R>, E>
Like map_collect_vec, but for fallible mapping.
After an error, remaining items may be skipped. If multiple items fail, any of their errors may be returned. Successful results preserve batch order.