parent
298ba34c3c
commit
e6198debd6
|
@ -1,21 +1,14 @@
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate lazy_static;
|
extern crate lazy_static;
|
||||||
|
|
||||||
use std::sync::RwLock;
|
|
||||||
|
|
||||||
//TODO remove this hack when rayon fixes itself
|
//TODO remove this hack when rayon fixes itself
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
// reduce the number of threads each pool is allowed to half the cpu core count, to avoid rayon
|
// reduce the number of threads each pool is allowed to half the cpu core count, to avoid rayon
|
||||||
// hogging cpu
|
// hogging cpu
|
||||||
static ref MAX_RAYON_THREADS: RwLock<usize> =
|
static ref MAX_RAYON_THREADS: usize = sys_info::cpu_num().unwrap() as usize / 2;
|
||||||
RwLock::new(sys_info::cpu_num().unwrap() as usize / 2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_thread_count() -> usize {
|
pub fn get_thread_count() -> usize {
|
||||||
*MAX_RAYON_THREADS.read().unwrap()
|
*MAX_RAYON_THREADS
|
||||||
}
|
|
||||||
|
|
||||||
pub fn set_thread_count(count: usize) {
|
|
||||||
*MAX_RAYON_THREADS.write().unwrap() = count;
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue