pub struct JoinHandleBorrowed<'storage, T = ()> { /* private fields */ }Expand description
Owning handle to a spawned RTOS thread.
Drop semantics are cooperative-cancel + join (not detach):
Dropcallsrequest_stopthen waits for the worker to finish (the substrate’s join wait).detachopts 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>
impl<'storage, T> JoinHandleBorrowed<'storage, T>
Sourcepub fn thread(&self) -> Thread
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.
Sourcepub fn request_stop(&self)
pub fn request_stop(&self)
Request the thread to stop cooperatively. See Thread::request_stop.
Sourcepub fn stop_token(&self) -> StopToken
pub fn stop_token(&self) -> StopToken
Get a StopToken referencing this thread’s cancellation flag.
Sourcepub fn stop_requested(&self) -> bool
pub fn stop_requested(&self) -> bool
true if request_stop has been called.
Sourcepub fn join(self) -> Result<T>
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).
Sourcepub fn detach(self)
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.
Sourcepub fn raw_handle(&self) -> ove_thread_t
pub fn raw_handle(&self) -> ove_thread_t
Raw handle accessor for advanced use.
Sourcepub fn suspend(&self)
pub fn suspend(&self)
Suspend the running thread. See Thread::suspend.
Sourcepub fn resume(&self)
pub fn resume(&self)
Resume the running thread. See Thread::resume.
Sourcepub fn set_priority(&self, prio: Priority)
pub fn set_priority(&self, prio: Priority)
Change the running thread’s priority. See Thread::set_priority.
Sourcepub fn get_state(&self) -> ThreadState
pub fn get_state(&self) -> ThreadState
Read the running thread’s state. See Thread::get_state.
Sourcepub fn get_stack_usage(&self) -> usize
pub fn get_stack_usage(&self) -> usize
Read the running thread’s stack usage. See Thread::get_stack_usage.
Sourcepub fn get_runtime_stats(&self) -> Result<ThreadStats>
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>
impl<'storage, T> Debug for JoinHandleBorrowed<'storage, T>
Source§impl<'storage, T> Drop for JoinHandleBorrowed<'storage, T>
impl<'storage, T> Drop for JoinHandleBorrowed<'storage, T>
Source§fn drop(&mut self)
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.