- Commit
- d7ba71e901322111ef30b6a4c62766c2a9a39c3f
- Parent
- 43c66e512f41679884e4e954d5bcaac53fae412c
- Author
- Gark Garcia <37553739+GarkGarcia@users.noreply.github.com>
- Date
Further documented the Rust implementation.
An exercise on polyglossy: the same problem solved on multiple languages
Further documented the Rust implementation.
1 file changed, 4 insertions, 1 deletion
Status | File Name | N° Changes | Insertions | Deletions |
Modified | Rust/src/main.rs | 5 | 4 | 1 |
diff --git a/Rust/src/main.rs b/Rust/src/main.rs @@ -60,9 +60,12 @@ fn get_countrexpl(max: usize, n_threads: usize) -> Option<(usize, usize)> { for i in 0..n_threads { let thread_countr_sd = coutexpl_sender.clone(); - let thread_range = (i..max).step_by(n_threads); let thread_sums = sums_cache.clone(); + // By separating the interval [0..max] in subsections with the form [i + 0n, i + 1n, i + 2n, ...] we can ensure that every + // value will get tested on a single thread and that all threads will perform roughtly the same number of operations + let thread_range = (i..max).step_by(n_threads); + let child = thread::spawn(move || thread_countr_sd.send(get_iter_countrexpl(thread_range, thread_sums, max)) .expect(&format!("Thread n°{} was unable to sent a message trought the channel", i)));