Skip to content

Commit 041a0a8

Browse files
committed
Use std::thread::available_parallelism for determining the default number of jobs
The function was stabilized in 1.59, while the current MSRV is 1.63.
1 parent 59578ad commit 041a0a8

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/parallel/job_token.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,10 @@ mod inprocess_jobserver {
238238
// Note that we could use `num_cpus` here but it's an extra
239239
// dependency that will almost never be used, so
240240
// it's generally not too worth it.
241-
let mut parallelism = 4;
242-
// TODO: Use std::thread::available_parallelism as an upper bound
243-
// when MSRV is bumped.
241+
242+
let mut parallelism = std::thread::available_parallelism()
243+
.map(|v| u32::from(v))
244+
.unwrap_or(4);
244245
if let Ok(amt) = var("NUM_JOBS") {
245246
if let Ok(amt) = amt.parse() {
246247
parallelism = amt;

0 commit comments

Comments
 (0)