pub trait ParallelRunner {
type Executor: ParallelExecutor;
type ThreadPool: ParThreadPool;
// Required methods
fn thread_pool(&self) -> &Self::ThreadPool;
fn thread_pool_mut(&mut self) -> &mut Self::ThreadPool;
// Provided methods
fn new_executor(
&self,
kind: ComputationKind,
params: Params,
initial_input_len: Option<usize>,
) -> Self::Executor { ... }
fn run_all<I, F>(
&mut self,
params: Params,
iter: I,
kind: ComputationKind,
thread_do: F,
) -> NumSpawned
where I: ConcurrentIter,
F: Fn(NumSpawned, &I, &<Self::Executor as ParallelExecutor>::SharedState, <Self::Executor as ParallelExecutor>::ThreadExecutor) + Sync { ... }
fn map_all<F, I, M, T>(
&mut self,
params: Params,
iter: I,
kind: ComputationKind,
thread_map: M,
) -> (NumSpawned, Result<Vec<T>, <F as Fallibility>::Error>)
where F: Fallibility,
I: ConcurrentIter,
M: Fn(NumSpawned, &I, &<Self::Executor as ParallelExecutor>::SharedState, <Self::Executor as ParallelExecutor>::ThreadExecutor) -> Result<T, <F as Fallibility>::Error> + Sync,
T: Send,
<F as Fallibility>::Error: Send { ... }
fn map_infallible<I, M, T>(
&mut self,
params: Params,
iter: I,
kind: ComputationKind,
thread_map: M,
) -> (NumSpawned, Result<Vec<T>, Never>)
where I: ConcurrentIter,
M: Fn(NumSpawned, &I, &<Self::Executor as ParallelExecutor>::SharedState, <Self::Executor as ParallelExecutor>::ThreadExecutor) -> Result<T, Never> + Sync,
T: Send { ... }
fn max_num_threads_for_computation(
&self,
params: Params,
iter_len: Option<usize>,
) -> NonZero<usize> { ... }
}Expand description
Parallel runner defining how the threads must be spawned and job must be distributed.
Required Associated Typesยง
Sourcetype Executor: ParallelExecutor
type Executor: ParallelExecutor
Parallel executor responsible for distribution of tasks to the threads.
Sourcetype ThreadPool: ParThreadPool
type ThreadPool: ParThreadPool
Thread pool responsible for providing threads to the parallel computation.
Required Methodsยง
Sourcefn thread_pool(&self) -> &Self::ThreadPool
fn thread_pool(&self) -> &Self::ThreadPool
Reference to the underlying thread pool.
Sourcefn thread_pool_mut(&mut self) -> &mut Self::ThreadPool
fn thread_pool_mut(&mut self) -> &mut Self::ThreadPool
Mutable reference to the underlying thread pool.
Provided Methodsยง
Sourcefn new_executor(
&self,
kind: ComputationKind,
params: Params,
initial_input_len: Option<usize>,
) -> Self::Executor
fn new_executor( &self, kind: ComputationKind, params: Params, initial_input_len: Option<usize>, ) -> Self::Executor
Creates a new parallel executor for a parallel computation.
Sourcefn run_all<I, F>(
&mut self,
params: Params,
iter: I,
kind: ComputationKind,
thread_do: F,
) -> NumSpawnedwhere
I: ConcurrentIter,
F: Fn(NumSpawned, &I, &<Self::Executor as ParallelExecutor>::SharedState, <Self::Executor as ParallelExecutor>::ThreadExecutor) + Sync,
fn run_all<I, F>(
&mut self,
params: Params,
iter: I,
kind: ComputationKind,
thread_do: F,
) -> NumSpawnedwhere
I: ConcurrentIter,
F: Fn(NumSpawned, &I, &<Self::Executor as ParallelExecutor>::SharedState, <Self::Executor as ParallelExecutor>::ThreadExecutor) + Sync,
Runs thread_do using threads provided by the thread pool.
Sourcefn map_all<F, I, M, T>(
&mut self,
params: Params,
iter: I,
kind: ComputationKind,
thread_map: M,
) -> (NumSpawned, Result<Vec<T>, <F as Fallibility>::Error>)where
F: Fallibility,
I: ConcurrentIter,
M: Fn(NumSpawned, &I, &<Self::Executor as ParallelExecutor>::SharedState, <Self::Executor as ParallelExecutor>::ThreadExecutor) -> Result<T, <F as Fallibility>::Error> + Sync,
T: Send,
<F as Fallibility>::Error: Send,
fn map_all<F, I, M, T>(
&mut self,
params: Params,
iter: I,
kind: ComputationKind,
thread_map: M,
) -> (NumSpawned, Result<Vec<T>, <F as Fallibility>::Error>)where
F: Fallibility,
I: ConcurrentIter,
M: Fn(NumSpawned, &I, &<Self::Executor as ParallelExecutor>::SharedState, <Self::Executor as ParallelExecutor>::ThreadExecutor) -> Result<T, <F as Fallibility>::Error> + Sync,
T: Send,
<F as Fallibility>::Error: Send,
Runs thread_map using threads provided by the thread pool.
Sourcefn map_infallible<I, M, T>(
&mut self,
params: Params,
iter: I,
kind: ComputationKind,
thread_map: M,
) -> (NumSpawned, Result<Vec<T>, Never>)where
I: ConcurrentIter,
M: Fn(NumSpawned, &I, &<Self::Executor as ParallelExecutor>::SharedState, <Self::Executor as ParallelExecutor>::ThreadExecutor) -> Result<T, Never> + Sync,
T: Send,
fn map_infallible<I, M, T>(
&mut self,
params: Params,
iter: I,
kind: ComputationKind,
thread_map: M,
) -> (NumSpawned, Result<Vec<T>, Never>)where
I: ConcurrentIter,
M: Fn(NumSpawned, &I, &<Self::Executor as ParallelExecutor>::SharedState, <Self::Executor as ParallelExecutor>::ThreadExecutor) -> Result<T, Never> + Sync,
T: Send,
Runs infallible thread_map using threads provided by the thread pool.
Dyn Compatibilityยง
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".