use std::thread::available_parallelism;
pub trait WorkerInit<T, R, F>
where
Self: Sized,
{
fn with_num_threads(num_worker_threads: usize, worker_function: F) -> Self;
fn new(worker_function: F) -> Self {
let num_worker_threads = available_parallelism()
.map(|n| n.get().saturating_sub(1))
.unwrap_or(1);
Self::with_num_threads(num_worker_threads, worker_function)
}
}