mirror of
https://github.com/bootandy/dust.git
synced 2025-12-12 07:40:40 -08:00
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:
13
src/main.rs
13
src/main.rs
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user