Skip to content

Commit 7840ce9

Browse files
committed
cli: Replace num_cpus with std::available_parallelism
1 parent bb1a53f commit 7840ce9

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust-code-analysis-cli/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ name = "rust-code-analysis-cli"
1414
[dependencies]
1515
clap = { version = "^3.0", features = ["cargo"] }
1616
globset = "^0.4"
17-
num_cpus = "^1.13"
1817
regex = "^1.5"
1918
rust-code-analysis = { path = "..", version = "0.0"}
2019
serde = "^1.0"

rust-code-analysis-cli/src/main.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use std::path::{Path, PathBuf};
88
use std::process;
99
use std::str::FromStr;
1010
use std::sync::{Arc, Mutex};
11+
use std::thread::available_parallelism;
1112

1213
use formats::Format;
1314

@@ -394,7 +395,12 @@ fn main() {
394395
let num_jobs = if let Ok(num_jobs) = matches.value_of("num_jobs").unwrap().parse::<usize>() {
395396
std::cmp::max(2, num_jobs) - 1
396397
} else {
397-
std::cmp::max(2, num_cpus::get()) - 1
398+
std::cmp::max(
399+
2,
400+
available_parallelism()
401+
.expect("Unrecoverable: Failed to get thread count")
402+
.get(),
403+
) - 1
398404
};
399405

400406
let line_start = if let Ok(n) = matches.value_of("line_start").unwrap().parse::<usize>() {

0 commit comments

Comments
 (0)