Skip to main content

CpuSet

Struct CpuSet 

Source
pub struct CpuSet { /* private fields */ }
Expand description

A set of CPU IDs.

CpuSet represents a collection of CPU cores, typically used for thread affinity. It supports up to 1024 CPUs, matching the Linux kernel limit.

Implementations§

Source§

impl CpuSet

Source

pub const MAX_CPUS: usize = 1024

Maximum number of CPUs supported.

Source

pub const fn new() -> CpuSet

Create an empty CPU set.

Source

pub fn single(cpu: u32) -> CpuSet

Create a CPU set containing a single CPU.

Source

pub fn add(&mut self, cpu: u32)

Add a CPU to the set.

§Panics

Panics if cpu >= MAX_CPUS.

Source

pub fn remove(&mut self, cpu: u32)

Remove a CPU from the set.

Source

pub fn contains(&self, cpu: u32) -> bool

Check if a CPU is in the set.

Source

pub fn is_empty(&self) -> bool

Check if the set is empty.

Source

pub fn count(&self) -> usize

Count the number of CPUs in the set.

Source

pub fn iter(&self) -> impl Iterator<Item = u32>

Iterate over the CPUs in the set.

Source

pub fn first(&self) -> Option<u32>

Get the first CPU in the set, if any.

Source

pub fn union(&self, other: &CpuSet) -> CpuSet

Create a union of two CPU sets.

Source

pub fn intersection(&self, other: &CpuSet) -> CpuSet

Create an intersection of two CPU sets.

Source

pub fn as_raw(&self) -> &[u64; 16]

Get the raw bitmap for FFI.

Source

pub fn as_raw_mut(&mut self) -> &mut [u64; 16]

Get a mutable reference to the raw bitmap for FFI.

Source

pub fn parse(s: &str) -> Result<CpuSet, ParseCpuSetError>

Parse a CPU list string like “0-3,8-11” or “0,1,2,3”.

Trait Implementations§

Source§

impl Clone for CpuSet

Source§

fn clone(&self) -> CpuSet

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CpuSet

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for CpuSet

Source§

fn default() -> CpuSet

Returns the “default value” for a type. Read more
Source§

impl Display for CpuSet

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl FromIterator<u32> for CpuSet

Source§

fn from_iter<I>(iter: I) -> CpuSet
where I: IntoIterator<Item = u32>,

Creates a value from an iterator. Read more
Source§

impl PartialEq for CpuSet

Source§

fn eq(&self, other: &CpuSet) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for CpuSet

Source§

impl StructuralPartialEq for 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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.