a-conjecture-of-mine

An exercise on polyglossy: the same problem solved on multiple languages

commit d7ba71e901322111ef30b6a4c62766c2a9a39c3f
parent 43c66e512f41679884e4e954d5bcaac53fae412c
Author: Gark Garcia <37553739+GarkGarcia@users.noreply.github.com>
Date:   Fri, 14 Jun 2019 18:13:23 -0300

Further documented the Rust implementation.

Diffstat:
MRust/src/main.rs | 5++++-
1 file changed, 4 insertions(+), 1 deletion(-)
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)));