Skip to content

Commit 271cb8e

Browse files
committed
web: Replace num_cpus with std::available_parallelism
1 parent 7840ce9 commit 271cb8e

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-web/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ actix-rt = "^2.6"
1616
actix-web = "^3.3"
1717
clap = { version = "^3.1", features = ["derive"] }
1818
futures = "^0.3"
19-
num_cpus = "^1.13"
2019
rust-code-analysis = { path = "..", version = "0.0" }
2120
serde = "^1.0"
2221
serde_json = "^1.0"

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#![recursion_limit = "256"]
66
mod web;
77

8+
use std::thread::available_parallelism;
9+
810
use clap::Parser;
911

1012
use web::server;
@@ -32,7 +34,11 @@ struct Opts {
3234
async fn main() {
3335
let opts = Opts::parse();
3436

35-
let num_jobs = opts.num_jobs.unwrap_or_else(num_cpus::get);
37+
let num_jobs = opts.num_jobs.unwrap_or(
38+
available_parallelism()
39+
.expect("Unrecoverable: Failed to get thread count")
40+
.get(),
41+
);
3642

3743
if let Err(e) = server::run(&opts.host, opts.port, num_jobs).await {
3844
eprintln!(

0 commit comments

Comments
 (0)