Moved thread pool initialisation to Args::post_process
parent
d1e027e00c
commit
6b17a3cb06
10
src/args.rs
10
src/args.rs
|
@ -1,5 +1,6 @@
|
|||
use clap::{Parser, ArgAction};
|
||||
use glob::Pattern;
|
||||
use rayon::ThreadPoolBuilder;
|
||||
|
||||
use crate::unit::Unit;
|
||||
|
||||
|
@ -150,6 +151,11 @@ impl Args {
|
|||
self.path = vec![ ".".to_owned() ];
|
||||
}
|
||||
|
||||
ThreadPoolBuilder::new()
|
||||
.num_threads(self.threads)
|
||||
.build_global()
|
||||
.expect("Failed to initialise threadpool");
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
|
@ -195,10 +201,6 @@ impl Args {
|
|||
pub const fn quiet(&self) -> bool {
|
||||
self.quiet
|
||||
}
|
||||
|
||||
pub const fn threads(&self) -> usize {
|
||||
self.threads
|
||||
}
|
||||
|
||||
pub fn paths(&self) -> Iter<'_, String> {
|
||||
self.path.iter()
|
||||
|
|
11
src/main.rs
11
src/main.rs
|
@ -8,23 +8,12 @@ use clap::Parser;
|
|||
|
||||
use args::Args;
|
||||
use directory::Directory;
|
||||
use rayon::ThreadPoolBuilder;
|
||||
|
||||
use std::process::ExitCode;
|
||||
|
||||
fn main() -> ExitCode {
|
||||
let args = Args::parse().post_process();
|
||||
|
||||
match ThreadPoolBuilder::new().num_threads(args.threads()).build_global() {
|
||||
Ok(()) => (),
|
||||
Err(e) => {
|
||||
if !args.minimal() && !args.quiet() {
|
||||
eprintln!("hb: {e}");
|
||||
}
|
||||
return ExitCode::FAILURE;
|
||||
}
|
||||
};
|
||||
|
||||
let mut total = 0;
|
||||
for path in args.paths() {
|
||||
let dir_structure = match Directory::new(path, &args) {
|
||||
|
|
Loading…
Reference in New Issue