pub struct TaskHandle {
pub id: u16,
pub generation: u32,
}Expand description
Handle to a spawned preemptive task: the registry slot id plus the slot’s generation counter, so stale handles can be detected after the slot was recycled (plan.md §4.3 / §5.1).
Fields§
§id: u16§generation: u32Implementations§
Source§impl TaskHandle
impl TaskHandle
Sourcepub fn is_valid(&self) -> bool
pub fn is_valid(&self) -> bool
Whether the handle still refers to the same task (slot not recycled).
Sourcepub fn request_stop(&self) -> bool
pub fn request_stop(&self) -> bool
Ask the task to stop cooperatively (plan.md §5.4): sets the
stop-requested flag, which the task polls via
lifecycle::should_stop. Returns false if the handle is stale.
Sourcepub fn join<T: 'static + Send>(&self) -> Result<T, JoinError>
pub fn join<T: 'static + Send>(&self) -> Result<T, JoinError>
Block until the task’s entry returns, then recover its result
(plan.md §5.2/§5.3). See JoinError.
Sourcepub fn set_period_us(&self, period_us: u32)
pub fn set_period_us(&self, period_us: u32)
Configure this task’s period (plan.md Phase 11): the task itself
calls crate::deadlines::wait_period once per iteration to block
until the next boundary. 0 disables periodic waiting. No-op on a
stale handle.
Sourcepub fn set_budget_us(&self, budget_us: u32)
pub fn set_budget_us(&self, budget_us: u32)
Configure this task’s per-period CPU budget in microseconds
(plan.md Phase 11, estimated via
crate::exec_time::estimate_us_from_cycles). Exceeding it inside
one period raises crate::fault::FaultKind::BudgetExceeded
through the normal fault policy. 0 disables enforcement. No-op on
a stale handle. Meaningless without also calling
Self::set_period_us — the budget window resets at each period
boundary.
Sourcepub fn despawn(&self) -> bool
pub fn despawn(&self) -> bool
Release the task’s slot and stack for reuse (plan.md §5.4). The
task must have exited (join returned) or be a task other than the
current one that is blocked/suspended — despawning a running
task is rejected. Returns false for a stale handle.
Sourcepub fn pause(&self) -> bool
pub fn pause(&self) -> bool
Suspend the task (plan.md §5.5): a READY task moves to SUSPENDED and
is skipped by the scheduler until TaskHandle::resume. Returns
false for a stale handle or a task that isn’t currently READY.
Trait Implementations§
Source§impl Clone for TaskHandle
impl Clone for TaskHandle
Source§fn clone(&self) -> TaskHandle
fn clone(&self) -> TaskHandle
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more