diff options
author | Daniel Schadt <kingdread@gmx.de> | 2023-01-14 18:44:24 +0100 |
---|---|---|
committer | Daniel Schadt <kingdread@gmx.de> | 2023-01-14 18:44:24 +0100 |
commit | 922355a064698cf0c099f3656d02e89961f67602 (patch) | |
tree | 0c47bd74dcdce8d54396568a3784e88a7184f5a2 /src | |
parent | d87a968e39d37a49eb19f44f0081ca98ebc9c662 (diff) | |
download | hittekaart-922355a064698cf0c099f3656d02e89961f67602.tar.gz hittekaart-922355a064698cf0c099f3656d02e89961f67602.tar.bz2 hittekaart-922355a064698cf0c099f3656d02e89961f67602.zip |
make number of threads configurable per CLI
Diffstat (limited to 'src')
-rw-r--r-- | src/main.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs index 77af69f..9c3250e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,6 +4,7 @@ use clap::Parser; use color_eyre::eyre::{bail, Result}; use indicatif::{MultiProgress, ProgressBar, ProgressDrawTarget, ProgressStyle}; use is_terminal::IsTerminal; +use rayon::ThreadPoolBuilder; mod gpx; mod layer; @@ -16,11 +17,17 @@ struct Args { #[arg(required = true)] files: Vec<PathBuf>, + /// Minimum zoom level to generate tiles for. #[arg(long, default_value_t = 0)] min_zoom: u32, + /// Maximum zoom level to generate tiles for. #[arg(long, default_value_t = 19)] max_zoom: u32, + + /// Number of threads to use. Set to 0 to use all available CPU cores. + #[arg(long, short, default_value_t = 0)] + threads: usize, } fn main() -> Result<()> { @@ -32,6 +39,10 @@ fn main() -> Result<()> { bail!("Max zoom cannot be smaller than min zoom!"); } + ThreadPoolBuilder::new() + .num_threads(args.threads) + .build_global()?; + let progress_style = ProgressStyle::with_template("[{elapsed}] {prefix:.cyan} {wide_bar} {pos:.green}/{len}")?; let zoom_style = |