#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct NumaSocketsActive([bool; MaximumNumaSockets], u8);
impl Default for NumaSocketsActive
{
fn default() -> Self
{
let mut value = [false; MaximumNumaSockets];
value[0] = true;
return NumaSocketsActive(value, 1);
}
}
impl Active for NumaSocketsActive
{
type T = NumaSocketId;
const Maximum: usize = MaximumNumaSockets;
#[inline(always)]
fn constructor(index: usize) -> Self::T
{
NumaSocketId::fromU32(index as u32).unwrap()
}
#[inline(always)]
fn count(&self) -> usize
{
self.1 as usize
}
#[inline(always)]
fn none() -> Self
{
NumaSocketsActive([false; MaximumNumaSockets], 0)
}
#[inline(always)]
fn all() -> Self
{
NumaSocketsActive([true; MaximumNumaSockets], MaximumNumaSockets as u8)
}
#[inline(always)]
fn value(&self, index: usize) -> bool
{
debug_assert!(index < Self::Maximum, "index '{}' is not less than Maximum '{}'", index, Self::Maximum);
(self.0)[index]
}
#[inline(always)]
fn set(&mut self, index: usize, toValue: bool)
{
debug_assert!(index < Self::Maximum, "index '{}' is not less than Maximum '{}'", index, Self::Maximum);
if toValue
{
self.1 += 1
}
else
{
self.1 -= 1
}
(self.0)[index] = toValue;
}
}
impl NumaSocketsActive
{
pub fn asHexadecimalCoreMaskCString(&self) -> CString
{
let mut setBits = 0;
for index in 0..MaximumNumaSockets
{
if self.isEnabled(index)
{
setBits |= 1 << index
}
}
debug_assert!(Self::Maximum <= 256 && Self::Maximum >= 16, "Change format string size parameter from 2 to something else, as Maximum '{}' is outside of the range expected", Self::Maximum);
CString::new(format!("0x{:02}", setBits)).unwrap()
}
}