Skip to content

Commit

Permalink
thread limit support
Browse files Browse the repository at this point in the history
  • Loading branch information
Toyz committed Jan 1, 2025
1 parent d56b344 commit 9762741
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ struct Args {
/// Seed for the random number generator (Default: Current time)
#[arg(short, long)]
seed: Option<u64>,

/// Number of threads to use (Default: Number of cores)
#[arg(long)]
threads: Option<u64>,
}

static LOOKING_GLASS: Emoji<'_, '_> = Emoji("🔍 ", "");
Expand All @@ -71,6 +75,13 @@ static SEED: Emoji<'_, '_> = Emoji("🌱 ", "");

fn main() -> anyhow::Result<()> {
let mut args = Args::parse();
if args.threads.is_some() {
rayon::ThreadPoolBuilder::new()
.num_threads(args.threads.unwrap() as usize)
.build_global()
.expect("Failed to set thread count");
}

// If we want to pass the arguments to a function, we need to clone them
if args.input.starts_with("http") {
// use the writer
Expand Down

0 comments on commit 9762741

Please sign in to comment.