Skip to content

Commit 3d83555

Browse files
committed
use current thread runtime for single worker
1 parent 0938dee commit 3d83555

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/config/mod.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,17 @@ pub fn init_runtime () -> std::io::Result<Runtime> {
9090
.enable_io()
9191
.build()
9292
} else {
93-
let mut worker_threads = worker_threads.as_u64().unwrap_or(1) as usize;
94-
if worker_threads == 0 { worker_threads = 1 }
95-
Builder::new_multi_thread()
96-
.thread_name("librespeed-rs")
97-
.worker_threads(worker_threads)
98-
.enable_time()
99-
.enable_io()
100-
.build()
93+
let worker_threads = worker_threads.as_u64().unwrap_or(1) as usize;
94+
match worker_threads {
95+
0 | 1 => Builder::new_current_thread()
96+
.enable_io()
97+
.build(),
98+
_ => Builder::new_multi_thread()
99+
.thread_name("librespeed-rs")
100+
.worker_threads(worker_threads)
101+
.enable_io()
102+
.build(),
103+
}
101104
}
102105
}
103106

0 commit comments

Comments
 (0)