pub struct ThreadHandle { /* private fields */ }Expand description
A strong reference used to inspect and control a live thread.
Implementations§
Source§impl ThreadHandle
impl ThreadHandle
Sourcepub fn set_policy(&self, policy: SchedulePolicy) -> Result<(), TaskError>
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.
Sourcepub fn request_affinity(
&self,
affinity: CpuSet,
) -> Result<ThreadAffinityChange, TaskError>
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.
Sourcepub fn set_affinity_and_wait(&self, affinity: CpuSet) -> Result<(), TaskError>
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.
Sourcepub fn lookup(thread: ThreadId) -> Result<Self, TaskError>
pub fn lookup(thread: ThreadId) -> Result<Self, TaskError>
Looks up a generation-valid thread through the runtime-owned task system.
Sourcepub fn runtime(&self) -> Result<ThreadRuntimeSnapshot, TaskError>
pub fn runtime(&self) -> Result<ThreadRuntimeSnapshot, TaskError>
Returns a cumulative charged-runtime snapshot for a live thread.
Source§impl ThreadHandle
impl ThreadHandle
Sourcepub fn base_policy(&self) -> SchedulePolicy
pub fn base_policy(&self) -> SchedulePolicy
Returns the thread’s base scheduling policy.
Sourcepub fn effective_policy(&self) -> SchedulePolicy
pub fn effective_policy(&self) -> SchedulePolicy
Returns the policy after priority-inheritance donation is applied.
Sourcepub fn execution_reclaimed(&self) -> bool
pub fn execution_reclaimed(&self) -> bool
Reports physical execution-resource reclamation independently of logical exit.
Sourcepub fn state(&self) -> ThreadState
pub fn state(&self) -> ThreadState
Returns the most recently published lifecycle state.
Sourcepub fn downgrade(&self) -> WeakThreadHandle
pub fn downgrade(&self) -> WeakThreadHandle
Creates a non-owning lifecycle observer.
Sourcepub fn wake_handle(&self) -> ThreadWakeHandle
pub fn wake_handle(&self) -> ThreadWakeHandle
Creates a direct wake handle that does not consult the thread registry.
Sourcepub fn scheduler_fence_cpu(&self) -> Option<CpuId>
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.
Sourcepub fn assigned_cpu(&self) -> Option<CpuId>
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
impl ThreadHandle
Sourcepub fn extension(&self) -> Option<ThreadExtensionBorrow<'_>>
pub fn extension(&self) -> Option<ThreadExtensionBorrow<'_>>
Borrows the directly attached OS extension for the lifetime of this handle.
Sourcepub fn wait(&self) -> Result<i32, TaskError>
pub fn wait(&self) -> Result<i32, TaskError>
Waits for logical exit while retaining the task identity and OS extension.