pub fn run_pool_parallel_vec<Key, Data, CommonData, F, const D: usize>(
    iter: impl Iterator<Item = Key> + Send,
    common_data: &CommonData,
    closure: &F,
    number_of_thread: usize,
    capacity: usize,
    l: &LatticeCyclic<D>,
    default_data: &Data
) -> Result<Vec<Data>, ThreadAnyError>where
    CommonData: Sync,
    Key: Eq + Send + Clone + Sync + LatticeElementToIndex<D>,
    Data: Send + Clone,
    F: Sync + Clone + Fn(&Key, &CommonData) -> Data,
Expand description

run jobs in parallel. Similar to run_pool_parallel but return a vector.

Now a reference to the lattice must be given and key must implement the trait super::lattice::LatticeElementToIndex. super::lattice::LatticeElementToIndex::to_index will be use to insert the data inside the vector. While computing because the thread can operate out of order, fill the data not yet computed by default_data capacity is used to determine the capacity of the std::vec::Vec upon initiation (see std::vec::Vec::with_capacity).

Errors

Returns ThreadAnyError::ThreadNumberIncorrect is the number of threads is 0. Returns ThreadAnyError::Panic if a thread panicked. Contains the panic message.

Example

use lattice_qcd_rs::field::Su3Adjoint;
use lattice_qcd_rs::lattice::{LatticeCyclic, LatticeElementToIndex, LatticePoint};
use lattice_qcd_rs::thread::run_pool_parallel_vec;

let l = LatticeCyclic::<4>::new(1_f64, 4)?;
let c = 5_usize;
let result = run_pool_parallel_vec(
    l.get_points(),
    &c,
    &|i: &LatticePoint<4>, c: &usize| i[0] * c,
    4,
    l.number_of_canonical_links_space(),
    &l,
    &0,
)?;
let point = LatticePoint::new([3, 0, 5, 0].into());
assert_eq!(result[point.to_index(&l)], point[0] * c);