ThreadHandle

Struct ThreadHandle 

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

A thread handle can be used from within the thread to read or modify certain settings like the name or the cpu affinity.

§Example


use iceoryx2_bb_posix::thread::*;

let mut handle = ThreadHandle::from_self();
println!("I am running in a thread named {}", handle.get_name().expect(""));
println!("On the following CPU cores {:?}", handle.get_affinity().expect(""));

// only run on CPU 0
handle.set_affinity(0);

Implementations§

Source§

impl ThreadHandle

Source

pub fn from_self() -> ThreadHandle

Returns a handle to the callers thread.

Trait Implementations§

Source§

impl Debug for ThreadHandle

Source§

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

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

impl ThreadProperties for ThreadHandle

Source§

fn get_name(&self) -> Result<&ThreadName, ThreadGetNameError>

Returns the name of the thread.
Source§

fn get_affinity(&self) -> Result<Vec<usize>, ThreadSetAffinityError>

Returns a vector of numbers which represents the CPU cores in which the thread may run.
Source§

fn set_affinity( &mut self, cpu_core_ids: &[usize], ) -> Result<(), ThreadSetAffinityError>

Sets the threads affinity to the provided set of cpu core ids. If one of the cpu core id’s does not exist in the system the call will fail.

Auto Trait Implementations§

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.