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
impl ThreadHandle
Sourcepub fn from_self() -> ThreadHandle
pub fn from_self() -> ThreadHandle
Returns a handle to the callers thread.
Trait Implementations§
Source§impl Debug for ThreadHandle
impl Debug for ThreadHandle
Source§impl ThreadProperties for ThreadHandle
impl ThreadProperties for ThreadHandle
Source§fn get_name(&self) -> Result<&ThreadName, ThreadGetNameError>
fn get_name(&self) -> Result<&ThreadName, ThreadGetNameError>
Returns the name of the thread.
Source§fn get_affinity(&self) -> Result<Vec<usize>, ThreadSetAffinityError>
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>
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§
impl !Freeze for ThreadHandle
impl !RefUnwindSafe for ThreadHandle
impl Send for ThreadHandle
impl !Sync for ThreadHandle
impl Unpin for ThreadHandle
impl UnwindSafe for ThreadHandle
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more