Skip to content

Commit d6455ab

Browse files
committed
Add an env var to configure the runtime threadpool
1 parent e20b0f0 commit d6455ab

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/rt/mod.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ pub struct Runtime {}
1212
/// The global runtime.
1313
pub static RUNTIME: Lazy<Runtime> = Lazy::new(|| {
1414
// Create an executor thread pool.
15-
let num_threads = num_cpus::get().max(1);
15+
let num_threads = std::env::var("ASYNC_STD_RT_THREADS")
16+
.map(|env| env.parse().expect("ASYNC_STD_RT_THREADS must be a number"))
17+
.unwrap_or_else(|_| num_cpus::get())
18+
.max(1);
19+
1620
for _ in 0..num_threads {
1721
thread::Builder::new()
1822
.name("async-std/runtime".to_string())

0 commit comments

Comments
 (0)