Trait entangled::ParallelSlice [−][src]
Helper functions to iterate over a slice in parallel.
Provided methods
fn par_chunk_map<F, R>(
&self,
task_pool: &TaskPool,
chunk_size: usize,
f: F
) -> Vec<R> where
F: Fn(&[T]) -> R + Send + Sync,
R: Send + 'static,
[src]
&self,
task_pool: &TaskPool,
chunk_size: usize,
f: F
) -> Vec<R> where
F: Fn(&[T]) -> R + Send + Sync,
R: Send + 'static,
Iterates in parallel over a slice with a given chunk size.
Example
use entangled::*; let v = vec![42; 1000]; let task_pool = TaskPool::default(); let outputs = v.par_chunk_map(&task_pool, 512, |numbers| -> i32 { numbers.iter().sum() }); let mut sum = 0; for output in outputs { sum += output; } assert_eq!(sum, 1000 * 42);
fn par_splat_map<F, R>(
&self,
task_pool: &TaskPool,
max_tasks: Option<usize>,
f: F
) -> Vec<R> where
F: Fn(&[T]) -> R + Send + Sync,
R: Send + 'static,
[src]
&self,
task_pool: &TaskPool,
max_tasks: Option<usize>,
f: F
) -> Vec<R> where
F: Fn(&[T]) -> R + Send + Sync,
R: Send + 'static,
Iterates in parallel over a slice with a given maximum of tasks. max_tasks
is None, it
will use the thread number of the TaskPool
.
Example
use entangled::*; let v = vec![42; 1000]; let task_pool = TaskPool::default(); let outputs = v.par_splat_map(&task_pool, Some(2), |numbers| -> i32 { numbers.iter().sum() }); let mut sum = 0; for output in outputs { sum += output; } assert_eq!(sum, 1000 * 42);