Skip to content

Commit 85c20eb

Browse files
authored
Replace num_cpus crate with std::thread (#42)
1 parent 8562c41 commit 85c20eb

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ async-channel = "1.4.1"
2727
async-io = "1.1.9"
2828
criterion = { version = "0.4.0", default-features = false, features = ["cargo_bench_support"] }
2929
easy-parallel = "3.1.0"
30-
num_cpus = "1.13.0"
3130
once_cell = "1.16.0"
3231

3332
[[bench]]

benches/executor.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use std::future::Future;
2+
use std::thread::available_parallelism;
23

34
use async_executor::Executor;
45
use criterion::{criterion_group, criterion_main, Criterion};
@@ -11,7 +12,11 @@ const LIGHT_TASKS: usize = 25_000;
1112
static EX: Executor<'_> = Executor::new();
1213

1314
fn run(f: impl FnOnce(), multithread: bool) {
14-
let limit = if multithread { num_cpus::get() } else { 1 };
15+
let limit = if multithread {
16+
available_parallelism().unwrap().get()
17+
} else {
18+
1
19+
};
1520

1621
let (s, r) = async_channel::bounded::<()>(1);
1722
easy_parallel::Parallel::new()

0 commit comments

Comments
 (0)