Skip to main content

ThreadHandle

Struct ThreadHandle 

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

A strong reference used to inspect and control a live thread.

Implementations§

Source§

impl ThreadHandle

Source

pub fn set_policy(&self, policy: SchedulePolicy) -> Result<(), TaskError>

Updates a thread scheduling policy through its owner CPU.

§Errors

Returns TaskError::UnsafeContext in hard IRQ context and propagates policy validation, Deadline admission, identity, and CPU publication failures.

Source

pub fn affinity(&self) -> Result<CpuSet, TaskError>

Returns a copy of a thread’s CPU affinity.

Source

pub fn request_affinity( &self, affinity: CpuSet, ) -> Result<ThreadAffinityChange, TaskError>

Requests an affinity change and returns its owner-runqueue completion.

Dropping the completion leaves the request asynchronous. Use wait() or Self::set_affinity_and_wait when placement must finish before return.

Source

pub fn set_affinity_and_wait(&self, affinity: CpuSet) -> Result<(), TaskError>

Updates a remote thread’s affinity and waits for owner-runqueue completion.

A successful return guarantees that this update was ordered through the target’s owner runqueue. If no later setter superseded it, the target no longer executes on, is queued on, or has an in-flight transfer to a CPU excluded by this affinity. Setters that join the same outstanding owner transition share the target’s monotonically increasing completion sequence.

Source

pub fn lookup(thread: ThreadId) -> Result<Self, TaskError>

Looks up a generation-valid thread through the runtime-owned task system.

Source

pub fn runtime(&self) -> Result<ThreadRuntimeSnapshot, TaskError>

Returns a cumulative charged-runtime snapshot for a live thread.

Source§

impl ThreadHandle

Source

pub fn id(&self) -> ThreadId

Returns the generation-checked registry identity.

Source

pub fn base_policy(&self) -> SchedulePolicy

Returns the thread’s base scheduling policy.

Source

pub fn effective_policy(&self) -> SchedulePolicy

Returns the policy after priority-inheritance donation is applied.

Source

pub fn execution_reclaimed(&self) -> bool

Reports physical execution-resource reclamation independently of logical exit.

Source

pub fn state(&self) -> ThreadState

Returns the most recently published lifecycle state.

Source

pub fn downgrade(&self) -> WeakThreadHandle

Creates a non-owning lifecycle observer.

Source

pub fn wake_handle(&self) -> ThreadWakeHandle

Creates a direct wake handle that does not consult the thread registry.

Source

pub fn scheduler_fence_cpu(&self) -> Option<CpuId>

Returns the physical CPU that must cross a scheduler boundary.

Unlike direct wake placement, this snapshot remains on the source CPU until switch tail releases the outgoing context. A task-context caller can therefore publish state, take this snapshot, and rendezvous with the returned CPU; either the thread is still active there or it crossed a scheduler boundary after the publication.

Source

pub fn assigned_cpu(&self) -> Option<CpuId>

Returns Linux task_cpu(): the last committed runqueue assignment.

This remains the previous CPU while a task sleeps and changes to the destination when an rq-to-rq migration commits. Physical execution ownership is exposed separately by Self::scheduler_fence_cpu. A wake-placement hint is never reported as scheduler placement.

Source§

impl ThreadHandle

Source

pub fn extension(&self) -> Option<ThreadExtensionBorrow<'_>>

Borrows the directly attached OS extension for the lifetime of this handle.

Source

pub fn wait(&self) -> Result<i32, TaskError>

Waits for logical exit while retaining the task identity and OS extension.

Source

pub fn join(self) -> Result<i32, TaskError>

Waits for exit and transfers final reclamation to the task-context reaper.

Source

pub fn detach(self)

Relinquishes the caller’s management lease; the scheduler owns execution.

Trait Implementations§

Source§

impl Clone for ThreadHandle

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for ThreadHandle

Source§

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

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

impl Drop for ThreadHandle

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl Eq for ThreadHandle

Source§

impl PartialEq for ThreadHandle

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.