From b75b8f98b0b3c00e608778aa64d2c90bc3cddb97 Mon Sep 17 00:00:00 2001 From: Oleksandr Babak Date: Sun, 23 Mar 2025 11:49:08 +0100 Subject: [PATCH] doc: add a timely yield notice --- book/en/src/by-example/software_tasks.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/book/en/src/by-example/software_tasks.md b/book/en/src/by-example/software_tasks.md index f18e746def7..462c9e36b26 100644 --- a/book/en/src/by-example/software_tasks.md +++ b/book/en/src/by-example/software_tasks.md @@ -86,7 +86,7 @@ $ cargo xtask qemu --verbose --example spawn_arguments ## Divergent tasks -A task can have one of two signatures: `async fn({name}::Context, ..)` or `async fn({name}::Context, ..) -> !`. The latter defines a *divergent* task — one that never returns. The key advantage of divergent tasks is that they receive a `'static` context, and `local` resources have `'static` lifetime. Additionally, using this signature makes the task’s intent explicit, clearly distinguishing between short-lived tasks and those that run indefinitely. +A task can have one of two signatures: `async fn({name}::Context, ..)` or `async fn({name}::Context, ..) -> !`. The latter defines a *divergent* task — one that never returns. The key advantage of divergent tasks is that they receive a `'static` context, and `local` resources have `'static` lifetime. Additionally, using this signature makes the task’s intent explicit, clearly distinguishing between short-lived tasks and those that run indefinitely. Be mindful not to starve other tasks at the same priority level by ensuring you yield control with `.await`. ## Priority zero tasks