Skip to content

Commit

Permalink
Support Linux on MIPS and ARMv5TE
Browse files Browse the repository at this point in the history
Ensure to set num threads to 1 for thread pools when `num_cpus::get()` returns 0.
  • Loading branch information
tatsuya6502 committed Sep 10, 2021
1 parent d91c5ce commit 13263a2
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/common/thread_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ impl ThreadPoolRegistry {
// and insert a new pool.
let mut pools = REGISTRY.pools.write();
pools.entry(name).or_insert_with(|| {
let num_threads = num_cpus::get();
// Some platforms may return 0. In that case, use 1.
// https://github.com/moka-rs/moka/pull/39#issuecomment-916888859
// https://github.com/rust-lang/futures-rs/pull/1835
let num_threads = num_cpus::get().max(1);
let pool =
ScheduledThreadPool::with_name(name.thread_name_template(), num_threads);
let t_pool = ThreadPool {
Expand Down

0 comments on commit 13263a2

Please sign in to comment.