pub struct CpuSet { /* private fields */ }Expand description
Struct representing a bitmask to be used with the affinity functions.
Meant to represent the CPU_* macros from sched.h
Implementations§
Source§impl CpuSet
impl CpuSet
Sourcepub fn new(num_cpus: usize) -> CpuSet
pub fn new(num_cpus: usize) -> CpuSet
Create a new CpuSet with room for num_cpus CPUs, no cpu will be active.
Equivalent of CPU_ALLOC
Sourcepub fn from_mask<T>(mask: T) -> CpuSet
pub fn from_mask<T>(mask: T) -> CpuSet
Create a new CpuSet from a given mask. For example a u64 or a u8.
Sourcepub fn single(cpu: usize) -> CpuSet
pub fn single(cpu: usize) -> CpuSet
Create a new CpuSet that with one CPU set as active.
Shorthand for using new and set
Sourcepub fn set(&mut self, cpu: usize)
pub fn set(&mut self, cpu: usize)
Activate a given cpu on this CpuSet.
If the given cpu does not fit in the current CpuSet, it will be expanded to fit.
Equivalent of CPU_SET
Sourcepub fn clear(&mut self, cpu: usize)
pub fn clear(&mut self, cpu: usize)
Clear a given cpu on this CpuSet.
If the given cpu does not fit within the current CpuSet nothing will happen.
Equivalent of CPU_CLR.
Sourcepub fn is_set(&self, cpu: usize) -> bool
pub fn is_set(&self, cpu: usize) -> bool
Get if a given CPU is active in this CpuSet.
If cpu does not fit in this CpuSet false will be returned.
Equivalent of CPU_ISSET.
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Get the number of bytes in the mask.
Produces the same results as CPU_ALLOC_SIZE.
Sourcepub fn mask_ptr(&self) -> *const c_void
pub fn mask_ptr(&self) -> *const c_void
Get the raw pointer to the bitmask
Any modification of the CpuSet after this call might invalidate the pointer.
Sourcepub fn mut_mask_ptr(&mut self) -> *mut c_void
pub fn mut_mask_ptr(&mut self) -> *mut c_void
Get a mutable raw pointer to the bitmask.
Any modification of the CpuSet after this call might invalidate the pointer.
Sourcepub fn as_u64(&self) -> Result<u64, ()>
pub fn as_u64(&self) -> Result<u64, ()>
Represent this CpuSet as a u64.
Will return an Err if the CpuSet is too large to be written to a u64