Skip to main content

JoinHandleBorrowed

Struct JoinHandleBorrowed 

Source
pub struct JoinHandleBorrowed<'storage, T = ()> { /* private fields */ }
Expand description

Owning handle to a spawned RTOS thread.

Drop semantics are cooperative-cancel + join (not detach):

  • Drop calls request_stop then waits for the worker to finish (the substrate’s join wait).
  • detach opts out of the join-on-drop — the thread keeps running and the handle is consumed without destroying the kernel object.

The 'storage lifetime ties this handle to caller-provided storage in zero-heap mode. Heap-mode spawns return JoinHandle<T> (the 'storage = 'static alias) — kernel owns storage, no borrow. Zero-heap spawns return JoinHandleBorrowed<'storage, T> with the lifetime tied to the [ThreadStorage] reference passed to [Builder::spawn_static] / [Builder::spawn_static_simple], so the borrow checker prevents dropping the storage before the handle.

The T type parameter is reserved for future use (substrate doesn’t surface a worker’s return value today); ignore it and use JoinHandle<()>.

Implementations§

Source§

impl<'storage, T> JoinHandleBorrowed<'storage, T>

Source

pub fn thread(&self) -> Thread

Get a non-owning Thread view of the running thread. Use for signalling (suspend, set_priority, …) without giving away the owning handle.

Source

pub fn request_stop(&self)

Request the thread to stop cooperatively. See Thread::request_stop.

Source

pub fn stop_token(&self) -> StopToken

Get a StopToken referencing this thread’s cancellation flag.

Source

pub fn stop_requested(&self) -> bool

true if request_stop has been called.

Source

pub fn join(self) -> Result<T>

Wait for the worker to finish without requesting a stop first.

Returns once the worker’s entry function returns and the substrate has joined. For workers that loop forever without observing StopToken this blocks indefinitely — call request_stop beforehand if you need a cooperative shutdown.

T is always () today; the substrate doesn’t surface worker return values. The method signature reserves the parameter for a future expansion (matches std::thread::JoinHandle::join).

Source

pub fn detach(self)

Consume the handle without joining or requesting stop. The underlying kernel thread keeps running; its resources are leaked from the binding’s perspective (the RTOS may reap them when the entry function eventually returns).

Use this when the worker is fire-and-forget and you don’t want the join wait that Drop would otherwise do. Prefer it over core::mem::forget(handle) because the intent is visible at the call site.

Source

pub fn raw_handle(&self) -> ove_thread_t

Raw handle accessor for advanced use.

Source

pub fn suspend(&self)

Suspend the running thread. See Thread::suspend.

Source

pub fn resume(&self)

Resume the running thread. See Thread::resume.

Source

pub fn set_priority(&self, prio: Priority)

Change the running thread’s priority. See Thread::set_priority.

Source

pub fn get_state(&self) -> ThreadState

Read the running thread’s state. See Thread::get_state.

Source

pub fn get_stack_usage(&self) -> usize

Read the running thread’s stack usage. See Thread::get_stack_usage.

Source

pub fn get_runtime_stats(&self) -> Result<ThreadStats>

Read the running thread’s runtime stats. See Thread::get_runtime_stats.

Trait Implementations§

Source§

impl<'storage, T> Debug for JoinHandleBorrowed<'storage, T>

Source§

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

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

impl<'storage, T> Drop for JoinHandleBorrowed<'storage, T>

Source§

fn drop(&mut self)

Signals the cooperative-cancellation flag via Thread::request_stop then waits on the substrate’s join.

Workers built with Builder::spawn or Builder::spawn_cooperative (poll StopToken::is_stopped) exit cleanly without deadlocking. Workers built with Builder::spawn_simple still block the join if their entry function doesn’t return on its own — the stop flag is set but nothing observes it.

Suppressed entirely by JoinHandle::detach.

Source§

impl<'storage, T> Send for JoinHandleBorrowed<'storage, T>

Source§

impl<'storage, T> Sync for JoinHandleBorrowed<'storage, T>

Auto Trait Implementations§

§

impl<'storage, T> Freeze for JoinHandleBorrowed<'storage, T>

§

impl<'storage, T> RefUnwindSafe for JoinHandleBorrowed<'storage, T>

§

impl<'storage, T> Unpin for JoinHandleBorrowed<'storage, T>

§

impl<'storage, T> UnsafeUnpin for JoinHandleBorrowed<'storage, T>

§

impl<'storage, T> UnwindSafe for JoinHandleBorrowed<'storage, T>

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> 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.