pub trait ThreadPool: Send + Sync {
// Required methods
fn num_threads(&self) -> usize;
fn execute<F>(&self, f: F)
where F: FnOnce() + Send + 'static;
fn join<A, B, RA, RB>(&self, a: A, b: B) -> (RA, RB)
where A: FnOnce() -> RA + Send,
B: FnOnce() -> RB + Send,
RA: Send,
RB: Send;
fn for_each<F>(&self, range: Range<usize>, f: F)
where F: Fn(usize) + Send + Sync;
fn map_reduce<T, Map, Reduce>(
&self,
range: Range<usize>,
identity: T,
map: Map,
reduce: Reduce,
) -> T
where T: Clone + Send + Sync,
Map: Fn(usize) -> T + Send + Sync,
Reduce: Fn(T, T) -> T + Send + Sync;
}Expand description
Trait for custom thread pool implementations.
This allows using thread pools other than rayon’s global pool.
Required Methods§
Sourcefn num_threads(&self) -> usize
fn num_threads(&self) -> usize
Returns the number of threads in the pool.
Sourcefn join<A, B, RA, RB>(&self, a: A, b: B) -> (RA, RB)
fn join<A, B, RA, RB>(&self, a: A, b: B) -> (RA, RB)
Joins two closures, executing them potentially in parallel.
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.