Limit Rayon threadpool threads (#5871)

This commit is contained in:
Sagar Dhawan
2019-09-12 11:39:39 -07:00
committed by GitHub
parent 385086359c
commit c1d788880d
16 changed files with 73 additions and 30 deletions

View File

@@ -0,0 +1,18 @@
#[macro_use]
extern crate lazy_static;
use std::sync::RwLock;
//TODO remove this hack when rayon fixes itself
lazy_static! {
static ref MAX_RAYON_THREADS: RwLock<usize> =
RwLock::new(sys_info::cpu_num().unwrap() as usize);
}
pub fn get_thread_count() -> usize {
*MAX_RAYON_THREADS.read().unwrap()
}
pub fn set_thread_count(count: usize) {
*MAX_RAYON_THREADS.write().unwrap() = count;
}