From b834bb20b368006b9a2418a4df4ae88606318c0d Mon Sep 17 00:00:00 2001 From: Igor Katson Date: Wed, 20 Oct 2021 20:17:42 +0100 Subject: [PATCH] Add an option to override worker threads --- crates/rqbit/src/main.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/crates/rqbit/src/main.rs b/crates/rqbit/src/main.rs index a563a57..e95254d 100644 --- a/crates/rqbit/src/main.rs +++ b/crates/rqbit/src/main.rs @@ -84,6 +84,10 @@ struct Opts { /// The connect timeout, e.g. 1s, 1.5s, 100ms etc. #[clap(long = "peer-connect-timeout")] peer_connect_timeout: Option, + + /// How many threads to spawn for the executor. + #[clap(short = 't', long)] + worker_threads: Option, } fn init_logging(opts: &Opts) { @@ -118,7 +122,13 @@ fn main() -> anyhow::Result<()> { BlockingSpawner::new(false), ), false => ( - tokio::runtime::Builder::new_multi_thread(), + { + let mut b = tokio::runtime::Builder::new_multi_thread(); + if let Some(e) = opts.worker_threads { + b.worker_threads(e); + } + b + }, BlockingSpawner::new(true), ), };