Skip to content

Commit

Permalink
feat: allow controll of the maximum number of cpus using BELLMAN_NUM_…
Browse files Browse the repository at this point in the history
…CPUS

(cherry picked from commit 37686f8)
  • Loading branch information
dignifiedquire authored and str4d committed Jun 4, 2021
1 parent c0c013e commit d90bb21
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/multicore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#[cfg(feature = "multicore")]
mod implementation {
use std::env;

use crossbeam::{self, thread::Scope};
use futures::{Future, IntoFuture, Poll};
use futures_cpupool::{CpuFuture, CpuPool};
Expand All @@ -30,7 +32,17 @@ mod implementation {
}

pub fn new() -> Worker {
Self::new_with_cpus(num_cpus::get())
let cpus = if let Ok(num) = env::var("BELLMAN_NUM_CPUS") {
if let Ok(num) = num.parse() {
num
} else {
num_cpus::get()
}
} else {
num_cpus::get()
};

Self::new_with_cpus(cpus)
}

pub fn log_num_cpus(&self) -> u32 {
Expand Down

0 comments on commit d90bb21

Please sign in to comment.