use super::thread_executor::ThreadExecutor;
use crate::{
parameters::Params,
runner::{ComputationKind, NumSpawned},
};
use core::num::NonZeroUsize;
use orx_concurrent_iter::ConcurrentIter;
pub trait ParallelExecutor: Sized + Sync + 'static + Clone {
type SharedState: Send + Sync;
type ThreadExecutor: ThreadExecutor<SharedState = Self::SharedState>;
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,
thread_idx: usize,
shared_state: &Self::SharedState,
) -> Self::ThreadExecutor;
fn complete_task(self, shared_state: Self::SharedState);
}