Build :)
parent
36ceb99873
commit
66f7efd823
17
src/main.rs
17
src/main.rs
|
@ -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));
|
||||
|
|
Loading…
Reference in New Issue