Skip to main content

TaskHandle

Struct TaskHandle 

Source
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: u32

Implementations§

Source§

impl TaskHandle

Source

pub fn is_valid(&self) -> bool

Whether the handle still refers to the same task (slot not recycled).

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn resume(&self) -> bool

Resume a suspended task (plan.md §5.5). Returns false for a stale handle or a task that isn’t SUSPENDED.

Trait Implementations§

Source§

impl Clone for TaskHandle

Source§

fn clone(&self) -> TaskHandle

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 Copy for TaskHandle

Source§

impl Debug for TaskHandle

Source§

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

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

impl Eq for TaskHandle

Source§

impl PartialEq for TaskHandle

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for TaskHandle

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.