master
Benoît 2018-09-10 23:48:59 +02:00
parent 36ceb99873
commit 66f7efd823
1 changed files with 10 additions and 7 deletions

View File

@ -236,7 +236,7 @@ fn main() {
}));
}
for child in children {
child.join();
let _ = child.join();
}
// compute file hash in parallel
@ -249,8 +249,7 @@ fn main() {
println!("Use {} chunk(s) of size {}", modulus, chunk_size);
println!("Use {} chunk(s) of size {}", num_cpus - modulus, chunk_size - 1);
let mut guards = vec![];
let mut work = files_candidate.clone().lock().unwrap();
let mut work = files_candidate.lock().unwrap();
// Example from :
// https://stackoverflow.com/questions/33818141/how-do-i-pass-disjoint-slices-from-a-vector-to-different-threads
@ -261,6 +260,7 @@ fn main() {
let chunk_a = split_a.chunks_mut(chunk_size);
let chunk_b = split_b.chunks_mut(chunk_size - 1);
let mut guards = vec![];
for (i, slice) in chunk_a.chain(chunk_b).enumerate() {
// Spawn a thread operating on that subslice.
let guard = scope.spawn(move || {
@ -276,16 +276,19 @@ fn main() {
});
guards.push(guard);
}
for guard in guards {
let _ = guard.join();
}
});
for guard in guards {
guard.join();
}
for i in work.iter() {
println!("{}", i);
}
// TODO with work !
// check for each hash duplication
// if so --> log to file and remove from list (store to done vector)
t.fg(term::color::CYAN).unwrap();
let end = PreciseTime::now();
println!("{} seconds.", start.to(end));