Expand description
RTOS thread management.
The API splits the thread surface into three types so ownership, observation, and configuration each have a clear home:
Threadis a non-owning handle. Returned byThread::currentand byJoinHandle::thread. Carries the read-only and signal operations (get_state,get_stack_usage,set_priority,suspend/resume,request_stop, …). Dropping aThreadvalue does nothing.JoinHandleis the owning type returned byBuilder::spawn(and itsspawn_cooperative/spawn_simple/spawn_staticsiblings). On drop it callsJoinHandle::request_stopand waits for the worker to finish. UseJoinHandle::detachto opt out of the join-on-drop.Builderis the only way to spawn a new thread. Cooperative cancellation is opt-in via the closure signature (FnOnce(StopToken)vsfn()).
Spawning a cooperative worker:
ⓘ
let h = Thread::builder()
.name(c"worker")
.priority(Priority::Normal)
.stack_size(4096)
.spawn(|tok: StopToken| {
while !tok.is_stopped() { /* work */ }
})?;
// h goes out of scope -> request_stop + join, no deadlock.Spawning a self-terminating one-shot (no token):
ⓘ
fn entry() { /* one-shot work */ }
let _h = Thread::builder()
.name(c"oneshot")
.priority(Priority::Normal)
.stack_size(4096)
.spawn_simple(entry)?;Structs§
- Builder
- Fluent thread-spawn configuration. Construct via
Thread::builder. - Join
Handle Borrowed - Owning handle to a spawned RTOS thread.
- MemStats
- System heap statistics.
- Stop
Token - Read-only handle to a thread’s cooperative-cancellation flag.
- Thread
- Non-owning handle to an RTOS thread.
- Thread
Info - Snapshot of a single thread’s info.
- Thread
Stats - Runtime statistics for a thread.
Enums§
- Priority
- Thread priority levels, matching
ove_prio_t. - Thread
State - Thread state, matching
ove_thread_state_t.
Functions§
- get_
mem_ stats - Query system heap statistics.
- thread_
list - List all threads in the system.
Type Aliases§
- Join
Handle - Heap-mode
JoinHandle. Alias ofJoinHandleBorrowedwith'storage = 'static(kernel owns the storage, no caller borrow). Matches the shape ofstd::thread::JoinHandlefor source-level compatibility with std-style code.