maniac_runtime/utils/
mod.rs1pub mod bits;
2pub mod padded;
3pub mod parking;
4pub mod random;
5pub mod striped_atomic;
6
7pub use bits::*;
8use core_affinity::CoreId;
9pub use padded::*;
10pub use parking::*;
11pub use random::*;
12
13pub fn num_cpus() -> usize {
14 cpu_cores().len()
19}
20
21pub fn cpu_cores() -> &'static [CoreId] {
22 static CPU_CORES: once_cell::sync::Lazy<Box<Option<Vec<CoreId>>>> = once_cell::sync::Lazy::new(|| {
23 Box::new(core_affinity::get_core_ids())
24 });
25 match (*CPU_CORES).as_ref() {
26 Some(cores) => cores.as_slice(),
27 None => &[],
28 }
29}