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
  • Loading branch information
dignifiedquire committed Mar 25, 2019
1 parent e092cca commit 37686f8
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/multicore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
//! crossbeam but may be extended in the future to
//! allow for various parallelism strategies.

use std::env;
use std::any::Any;
use num_cpus;
use futures::{Future, IntoFuture, Poll};
Expand All @@ -28,7 +29,17 @@ impl Worker {
}

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 37686f8

Please sign in to comment.