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 as ParallelRunner>::Executor as ParallelExecutor>::SharedState, <<Self as ParallelRunner>::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::Error>)
where F: Fallibility,
I: ConcurrentIter,
M: Fn(NumSpawned, &I, &<<Self as ParallelRunner>::Executor as ParallelExecutor>::SharedState, <<Self as ParallelRunner>::Executor as ParallelExecutor>::ThreadExecutor) -> Result<T, F::Error> + Sync,
T: Send,
F::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 as ParallelRunner>::Executor as ParallelExecutor>::SharedState, <<Self as ParallelRunner>::Executor as ParallelExecutor>::ThreadExecutor) -> Result<T, Never> + Sync,
T: Send { ... }
fn max_num_threads_for_computation(
&self,
params: Params,
iter_len: Option<usize>,
) -> NonZeroUsize { ... }
}
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 as ParallelRunner>::Executor as ParallelExecutor>::SharedState, <<Self as ParallelRunner>::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 as ParallelRunner>::Executor as ParallelExecutor>::SharedState, <<Self as ParallelRunner>::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::Error>)where
F: Fallibility,
I: ConcurrentIter,
M: Fn(NumSpawned, &I, &<<Self as ParallelRunner>::Executor as ParallelExecutor>::SharedState, <<Self as ParallelRunner>::Executor as ParallelExecutor>::ThreadExecutor) -> Result<T, F::Error> + Sync,
T: Send,
F::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::Error>)where
F: Fallibility,
I: ConcurrentIter,
M: Fn(NumSpawned, &I, &<<Self as ParallelRunner>::Executor as ParallelExecutor>::SharedState, <<Self as ParallelRunner>::Executor as ParallelExecutor>::ThreadExecutor) -> Result<T, F::Error> + Sync,
T: Send,
F::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 as ParallelRunner>::Executor as ParallelExecutor>::SharedState, <<Self as ParallelRunner>::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 as ParallelRunner>::Executor as ParallelExecutor>::SharedState, <<Self as ParallelRunner>::Executor as ParallelExecutor>::ThreadExecutor) -> Result<T, Never> + Sync,
T: Send,
Runs infallible thread_map
using threads provided by the thread pool.
Sourcefn max_num_threads_for_computation(
&self,
params: Params,
iter_len: Option<usize>,
) -> NonZeroUsize
fn max_num_threads_for_computation( &self, params: Params, iter_len: Option<usize>, ) -> NonZeroUsize
Returns the maximum number of threads that can be used for the computation defined by
the params
and input iter_len
.
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.