October 2019
Intermediate to advanced
444 pages
10h 37m
English
In this recipe, we'll add some more threads to do map-style data processing. Follow these steps:
use std::thread;////// Doubles each element in the provided chunks in parallel and returns the results./// fn parallel_map(data: Vec<Vec<i32>>) -> Vec<thread::JoinHandle<Vec<i32>>> { data.into_iter() .map(|chunk| thread::spawn(move || chunk.into_iter().map(|c| c * 2).collect())) .collect()}
Read now
Unlock full access