Allow dust to run on single core machines

Force dust to use 2 threads if there is only 1 cpu
JWalk breaks if it tries to run on a single cpu

https://github.com/jessegrosjean/jwalk/issues/15

This is a hack because I can't figure out how to fix JWalk.
This code and the num_cpu crate can be removed when the bug is fixed

Also I have conflated cpus with cores while describing this issue. It is
very difficult to test as I don't have a single core machine.
This commit is contained in:
andy.boot
2020-01-18 22:04:08 +00:00
parent 350d695f7c
commit 3d2477e554

View File

@@ -96,12 +96,23 @@ fn main() {
}
};
let threads = options.value_of("threads").and_then(|threads| {
let temp_threads = options.value_of("threads").and_then(|threads| {
threads
.parse::<usize>()
.map_err(|_| eprintln!("Ignoring bad value for threads: {:?}", threads))
.ok()
});
// Bug in JWalk
// https://github.com/jessegrosjean/jwalk/issues/15
// We force it to use 2 threads if there is only 1 cpu
// as JWalk breaks if it tries to run on a single cpu
let threads = {
if temp_threads.is_none() && num_cpus::get() == 1 {
Some(2)
} else {
temp_threads
}
};
let depth = options.value_of("depth").and_then(|depth| {
depth