embassy-executor

Crates

git

Versions

std

Flavors

embassy_executor

Attribute Macro task

Source
#[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_size attribute must be 1 or greater.

ยง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
}