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::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ยง

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

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>, ) -> NonZero<usize>

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.

Implementations on Foreign Typesยง

Sourceยง

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

Implementorsยง