CpuSet

Struct CpuSet 

Source
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

Source

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

Source

pub fn from_mask<T>(mask: T) -> CpuSet

Create a new CpuSet from a given mask. For example a u64 or a u8.

Source

pub fn single(cpu: usize) -> CpuSet

Create a new CpuSet that with one CPU set as active. Shorthand for using new and set

Source

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

Source

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.

Source

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.

Source

pub fn len(&self) -> usize

Get the number of bytes in the mask. Produces the same results as CPU_ALLOC_SIZE.

Source

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.

Source

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.

Source

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

Source

pub fn set_affinity(&self, pid: i32) -> Result<(), ()>

Sets the affinity described by this CpuSet to a given pid.

Source

pub fn get_affinity(pid: i32, num_cpus: usize) -> Result<CpuSet, ()>

Fetch the affinity for a given pid as a CpuSet.

Auto Trait Implementations§

§

impl Freeze for CpuSet

§

impl RefUnwindSafe for CpuSet

§

impl Send for CpuSet

§

impl Sync for CpuSet

§

impl Unpin for CpuSet

§

impl UnwindSafe for CpuSet

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.