pub struct ThreadExtension { /* private fields */ }Expand description
Opaque OS-specific data attached to a thread.
Implementations§
Source§impl ThreadExtension
impl ThreadExtension
Sourcepub const unsafe fn new(data: usize, ops: &'static ThreadExtensionOps) -> Self
pub const unsafe fn new(data: usize, ops: &'static ThreadExtensionOps) -> Self
Creates an extension from opaque data and a static callback table.
§Safety
data must satisfy every callback contract in ops, and the owning OS
must ensure callbacks do not allocate, block, or re-enter the scheduler
when invoked as switch hooks. Task-context callbacks must return to the
dedicated service thread; abandoning that stack leaves their explicit
in-flight lifetime claim closed to prevent use-after-free.
Sourcepub fn with_scheduler_tick_cpu_time(
self,
accounting: Arc<SchedulerTickCpuTime>,
) -> Self
pub fn with_scheduler_tick_cpu_time( self, accounting: Arc<SchedulerTickCpuTime>, ) -> Self
Attaches IRQ-safe user/system CPU-time sampling to this thread.
The scheduler retains the capability and charges it directly from each periodic tick. No OS callback or deferred task work runs in hard IRQ.
Sourcepub unsafe fn with_running_policy_applied_hook(
self,
callback: RunningPolicyAppliedHook,
) -> Self
pub unsafe fn with_running_policy_applied_hook( self, callback: RunningPolicyAppliedHook, ) -> Self
Adds a bounded callback for base-policy changes applied to a running thread.
The callback runs after the scheduler releases the thread-state lock. The current CPU still owns the scheduler baton, so the callback is serialized with switch hooks for the same thread. Queued and inactive base-policy changes are observed through the policy snapshot passed to the next switch-in instead. PI donation does not change this value.
§Safety
callback must interpret data according to this extension, remain
valid for its complete lifetime, and perform only bounded operations.
It must not allocate, block, or re-enter the scheduler.
Sourcepub unsafe fn with_scheduler_tick_work(
self,
gate: Arc<SchedulerTickGate>,
callback: SchedulerTickTaskWork,
) -> Self
pub unsafe fn with_scheduler_tick_work( self, gate: Arc<SchedulerTickGate>, callback: SchedulerTickTaskWork, ) -> Self
Adds task-context work gated by scheduler tick interest.
The scheduler hard-IRQ path only publishes a typed deferred-work record. The callback runs later on the dedicated task-work service thread.
§Safety
callback must interpret data according to this extension, remain
valid for its complete lifetime, and return normally to the task-work
service. The callback may use task-context synchronization but must not
retain the borrowed extension data after it returns. It may return
[SchedulerTickWorkDisposition::Retry] only after a transient conflict
and before publishing any accounting, timer, or signal state.
Sourcepub const fn ops(&self) -> &'static ThreadExtensionOps
pub const fn ops(&self) -> &'static ThreadExtensionOps
Returns the callback table used as the extension type identity.
Sourcepub fn scheduler_tick_cpu_time(&self) -> Option<Arc<SchedulerTickCpuTime>>
pub fn scheduler_tick_cpu_time(&self) -> Option<Arc<SchedulerTickCpuTime>>
Clones the IRQ-safe CPU-time sampling capability.
Thread creation retains this capability alongside the extension.