Skip to content

Commit

Permalink
feat: add thread pool limitation for rayon
Browse files Browse the repository at this point in the history
  • Loading branch information
4o3F committed Oct 8, 2024
1 parent 35082a8 commit 0c0bbaa
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ struct Cli {
/// Commands
#[command(subcommand)]
command: Option<Commands>,

#[arg(long, default_value = "100", help = "Thread pool size")]
thread: usize,
}

#[derive(Subcommand)]
Expand Down Expand Up @@ -330,8 +333,6 @@ enum YoloCommands {

#[tokio::main]
async fn main() {
// env_logger::init();

// Do tracing init
let subscriber = tracing_subscriber::fmt()
.with_max_level(Level::TRACE)
Expand All @@ -342,6 +343,11 @@ async fn main() {

let cli = Cli::parse();

rayon::ThreadPoolBuilder::new()
.num_threads(cli.thread)
.build_global()
.unwrap();

match &cli.command {
Some(Commands::Common { command }) => match command {
CommonCommands::CropRectangle {
Expand Down

0 comments on commit 0c0bbaa

Please sign in to comment.