pub struct Thread { /* private fields */ }Expand description
Non-owning handle to an RTOS thread.
Returned by Thread::current and JoinHandle::thread. Dropping
a Thread does not destroy the underlying RTOS thread — use
JoinHandle for that. Carries the read-only and signal-only
operations (get_state, suspend/resume, request_stop, …).
Implementations§
Source§impl Thread
impl Thread
Sourcepub fn set_priority(&self, prio: Priority)
pub fn set_priority(&self, prio: Priority)
Set this thread’s priority.
Sourcepub fn get_stack_usage(&self) -> usize
pub fn get_stack_usage(&self) -> usize
Get current stack usage in bytes.
Sourcepub fn get_state(&self) -> ThreadState
pub fn get_state(&self) -> ThreadState
Get the thread’s current state.
Sourcepub fn get_runtime_stats(&self) -> Result<ThreadStats>
pub fn get_runtime_stats(&self) -> Result<ThreadStats>
Get runtime statistics (CPU time and utilization) for this thread.
§Errors
Returns an error if the RTOS does not support runtime statistics or the thread handle is invalid.
Sourcepub fn request_stop(&self)
pub fn request_stop(&self)
Request the thread to stop cooperatively.
Sets the per-thread atomic cancellation flag. The worker must
poll StopToken::is_stopped (via the token it received at
spawn time) for this to have any effect — the substrate does
NOT force-terminate. Safe from any context (ISR, other thread,
the thread itself). Idempotent; the flag is sticky.
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 Thread::request_stop has been called on this thread.
Sourcepub fn raw_handle(&self) -> ove_thread_t
pub fn raw_handle(&self) -> ove_thread_t
Raw handle accessor for advanced use.