Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion rust-code-analysis-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ name = "rust-code-analysis-cli"
[dependencies]
clap = { version = "^3.0", features = ["cargo"] }
globset = "^0.4"
num_cpus = "^1.13"
regex = "^1.5"
rust-code-analysis = { path = "..", version = "0.0"}
serde = "^1.0"
Expand Down
8 changes: 7 additions & 1 deletion rust-code-analysis-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use std::path::{Path, PathBuf};
use std::process;
use std::str::FromStr;
use std::sync::{Arc, Mutex};
use std::thread::available_parallelism;

use formats::Format;

Expand Down Expand Up @@ -394,7 +395,12 @@ fn main() {
let num_jobs = if let Ok(num_jobs) = matches.value_of("num_jobs").unwrap().parse::<usize>() {
std::cmp::max(2, num_jobs) - 1
} else {
std::cmp::max(2, num_cpus::get()) - 1
std::cmp::max(
2,
available_parallelism()
.expect("Unrecoverable: Failed to get thread count")
.get(),
) - 1
};

let line_start = if let Ok(n) = matches.value_of("line_start").unwrap().parse::<usize>() {
Expand Down
1 change: 0 additions & 1 deletion rust-code-analysis-web/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ actix-rt = "^2.6"
actix-web = "^3.3"
clap = { version = "^3.1", features = ["derive"] }
futures = "^0.3"
num_cpus = "^1.13"
rust-code-analysis = { path = "..", version = "0.0" }
serde = "^1.0"
serde_json = "^1.0"
Expand Down
8 changes: 7 additions & 1 deletion rust-code-analysis-web/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#![recursion_limit = "256"]
mod web;

use std::thread::available_parallelism;

use clap::Parser;

use web::server;
Expand Down Expand Up @@ -32,7 +34,11 @@ struct Opts {
async fn main() {
let opts = Opts::parse();

let num_jobs = opts.num_jobs.unwrap_or_else(num_cpus::get);
let num_jobs = opts.num_jobs.unwrap_or_else(|| {
available_parallelism()
.expect("Unrecoverable: Failed to get thread count")
.get()
});

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