Skip to main content

ParallelRunner

Trait ParallelRunner 

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

Source

type Executor: ParallelExecutor

Parallel executor responsible for distribution of tasks to the threads.

Source

type ThreadPool: ParThreadPool

Thread pool responsible for providing threads to the parallel computation.

Required Methods§

Source

fn thread_pool(&self) -> &Self::ThreadPool

Reference to the underlying thread pool.

Source

fn thread_pool_mut(&mut self) -> &mut Self::ThreadPool

Mutable reference to the underlying thread pool.

Provided Methods§

Source

fn new_executor( &self, kind: ComputationKind, params: Params, initial_input_len: Option<usize>, ) -> Self::Executor

Creates a new parallel executor for a parallel computation.

Source

fn run_all<I, F>( &mut self, params: Params, iter: I, kind: ComputationKind, thread_do: F, ) -> NumSpawned

Runs thread_do using threads provided by the thread pool.

Source

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.

Source

fn map_infallible<I, M, T>( &mut self, params: Params, iter: I, kind: ComputationKind, thread_map: M, ) -> (NumSpawned, Result<Vec<T>, Never>)

Runs infallible thread_map using threads provided by the thread pool.

Source

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".

Implementations on Foreign Types§

Source§

impl<O> ParallelRunner for &mut O
where O: ParallelRunner,

Implementors§