From 3d83555db6ada9d97f290bcabf1812d8a9a2fefe Mon Sep 17 00:00:00 2001 From: Ambareesh Balaji Date: Thu, 24 Apr 2025 10:01:05 +0000 Subject: [PATCH] use current thread runtime for single worker --- src/config/mod.rs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/config/mod.rs b/src/config/mod.rs index 8da0afc..9908337 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -90,14 +90,17 @@ pub fn init_runtime () -> std::io::Result { .enable_io() .build() } else { - let mut worker_threads = worker_threads.as_u64().unwrap_or(1) as usize; - if worker_threads == 0 { worker_threads = 1 } - Builder::new_multi_thread() - .thread_name("librespeed-rs") - .worker_threads(worker_threads) - .enable_time() - .enable_io() - .build() + let worker_threads = worker_threads.as_u64().unwrap_or(1) as usize; + match worker_threads { + 0 | 1 => Builder::new_current_thread() + .enable_io() + .build(), + _ => Builder::new_multi_thread() + .thread_name("librespeed-rs") + .worker_threads(worker_threads) + .enable_io() + .build(), + } } }