#[task]Expand description
Declares an async task that can be run by embassy-executor. The optional pool_size parameter can be used to specify how
many concurrent tasks can be spawned (default is 1) for the function.
The following restrictions apply:
- The function must be declared
async. - The function must not use generics.
- The optional
pool_sizeattribute must be 1 or greater.
With the metadata-name feature, the task is named after the function, or after the optional
name argument. See MetadataRef::set_name to replace it at runtime.
ยงExamples
Declaring a task taking no arguments:
#[embassy_executor::task]
async fn mytask() {
// Function body
}Declaring a task with a given pool size:
#[embassy_executor::task(pool_size = 4)]
async fn mytask() {
// Function body
}Declaring a task with an explicit name. With the metadata-name feature it is named
"blinker"; without it, the argument is ignored:
#[embassy_executor::task(name = "blinker")]
async fn mytask() {
// Function body
}