pub struct CpuMask<const SIZE: usize>where
BitsImpl<SIZE>: Bits,{ /* private fields */ }Expand description
A compact array of bits which represents a set of physical CPUs, implemented based on bitmaps::Bitmap.
The type used to store the cpumask will be the minimum unsigned integer type
required to fit the number of bits, from u8 to u128. If the size is 1,
bool is used. If the size exceeds 128, an array of u128 will be used,
sized as appropriately. The maximum supported size is currently 1024,
represented by an array [u128; 8].
Implementations§
Source§impl<const SIZE: usize> CpuMask<SIZE>where
BitsImpl<SIZE>: Bits,
impl<const SIZE: usize> CpuMask<SIZE>where
BitsImpl<SIZE>: Bits,
Sourcepub fn mask(bits: usize) -> Self
pub fn mask(bits: usize) -> Self
Construct a cpumask where every bit with index less than bits is
true, and every other bit is false.
Sourcepub fn from_value(data: <BitsImpl<SIZE> as Bits>::Store) -> Self
pub fn from_value(data: <BitsImpl<SIZE> as Bits>::Store) -> Self
Construct a cpumask from a value of the same type as its backing store.
Sourcepub fn from_raw_bits(value: usize) -> Self
pub fn from_raw_bits(value: usize) -> Self
Construct a cpumask from a raw usize value.
The value must be less than 2^SIZE, panick if the value is too large.
Sourcepub fn one_shot(index: usize) -> Self
pub fn one_shot(index: usize) -> Self
Construct a cpumask with a single bit set at the specified index.
The value must be less than SIZE, panick if the value is too large.
Sourcepub fn into_value(self) -> <BitsImpl<SIZE> as Bits>::Store
pub fn into_value(self) -> <BitsImpl<SIZE> as Bits>::Store
Convert this cpumask into a value of the type of its backing store.
Sourcepub fn as_value(&self) -> &<BitsImpl<SIZE> as Bits>::Store
pub fn as_value(&self) -> &<BitsImpl<SIZE> as Bits>::Store
Get a reference to this cpumask’s backing store.
Sourcepub fn set(&mut self, index: usize, value: bool) -> bool
pub fn set(&mut self, index: usize, value: bool) -> bool
Set the value of the bit at a given index.
Returns the previous value of the bit.
Sourcepub fn first_index(self) -> Option<usize>
pub fn first_index(self) -> Option<usize>
Find the index of the first true bit in the cpumask.
Sourcepub fn last_index(self) -> Option<usize>
pub fn last_index(self) -> Option<usize>
Find the index of the last true bit in the cpumask.
Sourcepub fn next_index(self, index: usize) -> Option<usize>
pub fn next_index(self, index: usize) -> Option<usize>
Find the index of the first true bit in the cpumask after index.
Sourcepub fn prev_index(self, index: usize) -> Option<usize>
pub fn prev_index(self, index: usize) -> Option<usize>
Find the index of the last true bit in the cpumask before index.
Sourcepub fn first_false_index(self) -> Option<usize>
pub fn first_false_index(self) -> Option<usize>
Find the index of the first false bit in the cpumask.
Sourcepub fn last_false_index(self) -> Option<usize>
pub fn last_false_index(self) -> Option<usize>
Find the index of the last false bit in the cpumask.
Sourcepub fn next_false_index(self, index: usize) -> Option<usize>
pub fn next_false_index(self, index: usize) -> Option<usize>
Find the index of the first false bit in the cpumask after index.
Sourcepub fn prev_false_index(self, index: usize) -> Option<usize>
pub fn prev_false_index(self, index: usize) -> Option<usize>
Find the index of the first false bit in the cpumask before index.
Trait Implementations§
Source§impl<const SIZE: usize> BitAndAssign for CpuMask<SIZE>where
BitsImpl<SIZE>: Bits,
impl<const SIZE: usize> BitAndAssign for CpuMask<SIZE>where
BitsImpl<SIZE>: Bits,
Source§fn bitand_assign(&mut self, rhs: Self)
fn bitand_assign(&mut self, rhs: Self)
&= operation. Read moreSource§impl<const SIZE: usize> BitOrAssign for CpuMask<SIZE>where
BitsImpl<SIZE>: Bits,
impl<const SIZE: usize> BitOrAssign for CpuMask<SIZE>where
BitsImpl<SIZE>: Bits,
Source§fn bitor_assign(&mut self, rhs: Self)
fn bitor_assign(&mut self, rhs: Self)
|= operation. Read moreSource§impl<const SIZE: usize> BitXorAssign for CpuMask<SIZE>where
BitsImpl<SIZE>: Bits,
impl<const SIZE: usize> BitXorAssign for CpuMask<SIZE>where
BitsImpl<SIZE>: Bits,
Source§fn bitxor_assign(&mut self, rhs: Self)
fn bitxor_assign(&mut self, rhs: Self)
^= operation. Read more