Skip to main content

Batches

Struct Batches 

Source
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>

Source

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.

Source

pub fn map_collect_vec<I, P, F, R>(self, prepare: P, map_op: F) -> Vec<R>
where I: IntoIterator<IntoIter: Send, Item: Send> + Send, P: FnOnce(Vec<Range<usize>>) -> I, F: Fn(I::Item) -> R + Send + Sync, R: Send,

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.

Source

pub fn try_map_collect_vec<I, P, F, R, E>( self, prepare: P, map_op: F, ) -> Result<Vec<R>, E>
where I: IntoIterator<IntoIter: Send, Item: Send> + Send, P: FnOnce(Vec<Range<usize>>) -> I, F: Fn(I::Item) -> Result<R, E> + Send + Sync, R: Send, E: Send,

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.

Trait Implementations§

Source§

impl<'scope, S: Debug + Strategy> Debug for Batches<'scope, S>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'scope, S> Freeze for Batches<'scope, S>

§

impl<'scope, S> RefUnwindSafe for Batches<'scope, S>

§

impl<'scope, S> Send for Batches<'scope, S>
where &'scope S: Send,

§

impl<'scope, S> Sync for Batches<'scope, S>
where &'scope S: Sync,

§

impl<'scope, S> Unpin for Batches<'scope, S>

§

impl<'scope, S> UnsafeUnpin for Batches<'scope, S>

§

impl<'scope, S> UnwindSafe for Batches<'scope, S>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.