pub trait ParallelExecutor:
Sized
+ Sync
+ 'static {
type SharedState: Send + Sync;
type ThreadExecutor: ThreadExecutor<SharedState = Self::SharedState>;
// Required methods
fn new(
kind: ComputationKind,
params: Params,
initial_input_len: Option<usize>,
max_num_threads: NonZeroUsize,
) -> Self;
fn new_shared_state(&self) -> Self::SharedState;
fn do_spawn_new<I>(
&self,
num_spawned: NumSpawned,
shared_state: &Self::SharedState,
iter: &I,
) -> bool
where I: ConcurrentIter;
fn new_thread_executor(
&self,
shared_state: &Self::SharedState,
) -> Self::ThreadExecutor;
}
Expand description
A parallel executor 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§
Data shared to the thread executors.
Sourcetype ThreadExecutor: ThreadExecutor<SharedState = Self::SharedState>
type ThreadExecutor: ThreadExecutor<SharedState = Self::SharedState>
Thread executor that is responsible for executing the tasks allocated to a thread.
Required Methods§
Sourcefn new(
kind: ComputationKind,
params: Params,
initial_input_len: Option<usize>,
max_num_threads: NonZeroUsize,
) -> Self
fn new( kind: ComputationKind, params: Params, initial_input_len: Option<usize>, max_num_threads: NonZeroUsize, ) -> Self
Creates a new parallel executor for the given computation kind
, parallelization params
and initial_input_len
.
Creates an initial shared state.
Sourcefn do_spawn_new<I>(
&self,
num_spawned: NumSpawned,
shared_state: &Self::SharedState,
iter: &I,
) -> boolwhere
I: ConcurrentIter,
fn do_spawn_new<I>(
&self,
num_spawned: NumSpawned,
shared_state: &Self::SharedState,
iter: &I,
) -> boolwhere
I: ConcurrentIter,
Returns true if it is beneficial to spawn a new thread provided that:
num_spawned
threads are already been spawned, andshared_state
is the current parallel execution state.
Sourcefn new_thread_executor(
&self,
shared_state: &Self::SharedState,
) -> Self::ThreadExecutor
fn new_thread_executor( &self, shared_state: &Self::SharedState, ) -> Self::ThreadExecutor
Creates a new thread executor 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.