pub struct ParallelExecutor { /* private fields */ }Expand description
Branch-level parallel executor.
Owns a lazily created pool with the configured worker count and a shutdown flag. Clones retain the same pool. The last external owner joins every worker; if a pool task releases the last owner, its return completes termination instead. Each call to Self::execute_branches runs the supplied workers in parallel (when enabled and above the branching threshold) and collects their results in input order.
Implementations§
Source§impl ParallelExecutor
impl ParallelExecutor
Sourcepub fn new(max_workers: usize) -> Self
pub fn new(max_workers: usize) -> Self
Build an executor with at most max_workers concurrent
branches. 0 disables parallel dispatch (every branch runs
sequentially).
Sourcepub fn shutdown(&self)
pub fn shutdown(&self)
Mark the executor as shut down. Subsequent
Self::execute_branches calls fall back to sequential
execution.
Sourcepub fn execute_branches<R, F>(&self, workers: &[F]) -> Vec<R>
pub fn execute_branches<R, F>(&self, workers: &[F]) -> Vec<R>
Run each worker and collect results in the same order. Uses
rayon’s work-stealing pool when Self::enabled is true and
the branch count is at least MIN_PARALLEL_BRANCHES;
otherwise falls back to sequential execution.
Trait Implementations§
Source§impl Clone for ParallelExecutor
impl Clone for ParallelExecutor
Source§impl Debug for ParallelExecutor
impl Debug for ParallelExecutor
Auto Trait Implementations§
impl !RefUnwindSafe for ParallelExecutor
impl !UnwindSafe for ParallelExecutor
impl Freeze for ParallelExecutor
impl Send for ParallelExecutor
impl Sync for ParallelExecutor
impl Unpin for ParallelExecutor
impl UnsafeUnpin for ParallelExecutor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more