Trait ParallelRunner

Source
pub trait ParallelRunner: Sized + Sync {
    type SharedState: Send + Sync;
    type ThreadRunner: ThreadRunner<SharedState = Self::SharedState>;

    // Required methods
    fn new(
        kind: ComputationKind,
        params: Params,
        initial_input_len: Option<usize>,
    ) -> Self;
    fn new_shared_state(&self) -> Self::SharedState;
    fn do_spawn_new<I>(
        &self,
        num_spawned: usize,
        shared_state: &Self::SharedState,
        iter: &I,
    ) -> bool
       where I: ConcurrentIter;
    fn new_thread_runner(
        &self,
        shared_state: &Self::SharedState,
    ) -> Self::ThreadRunner;
}
Expand description

A parallel runner which is responsible for taking a computation defined as a composition of iterator methods, spawns threads, shares tasks and returns the result of the parallel execution.

Required Associated Types§

Source

type SharedState: Send + Sync

Data shared to the thread runners.

Source

type ThreadRunner: ThreadRunner<SharedState = Self::SharedState>

Thread runner that is responsible for executing the tasks allocated to a thread.

Required Methods§

Source

fn new( kind: ComputationKind, params: Params, initial_input_len: Option<usize>, ) -> Self

Creates a new parallel runner for the given computation kind, parallelization params and initial_input_len.

Source

fn new_shared_state(&self) -> Self::SharedState

Creates an initial shared state.

Source

fn do_spawn_new<I>( &self, num_spawned: usize, shared_state: &Self::SharedState, iter: &I, ) -> bool
where I: ConcurrentIter,

Returns true if it is beneficial to spawn a new thread provided that:

  • num_spawned threads are already been spawned, and
  • shared_state is the current parallel execution state.
Source

fn new_thread_runner( &self, shared_state: &Self::SharedState, ) -> Self::ThreadRunner

Creates a new thread runner provided that the current parallel execution state is shared_state.

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.

Implementors§