Attribute Macro thread
#[thread]
Available on crate feature
threading
only.Expand description
Runs the function decorated with this attribute macro as a separate thread.
§Parameters
autostart
: (mandatory) autostart the thread.stacksize
: (optional) the size of the stack allocated to the thread (in bytes).priority
: (optional) the thread’s priority.no_wait
: (optional) don’t wait for system initialization to be finished before starting the thread.
§Examples
This starts a thread with default values:
ⓘ
#[ariel_os::thread(autostart)]
fn print_hello_world() {
println!("Hello world!");
}
This starts a thread with a stack size of 1024 bytes and a priority of 2:
ⓘ
// `stacksize` and `priority` can be arbitrary expressions.
#[ariel_os::thread(autostart, stacksize = 1024, priority = 2)]
fn print_hello_world() {
println!("Hello world!");
}
§Panics
This macro panics when the ariel-os
crate cannot be found as a dependency of the crate where
this macro is used.