structured concurrency
Making sure every task a function starts is finished or cancelled before the function returns.
Structured concurrency ties task lifetimes to a scope (join!, JoinSet dropped at scope end aborts its tasks), so no work outlives the code that started it.
Loading interactive…
Examples
tokio::join!(quote(300, ..), quote(200, ..), quote(100, ..))returns only after all three finish, in 300 ms rather than the 600 ms of awaiting them in turn.Dropping a
JoinSetaborts every task still in it, so no task outlives the function that owns the set.
See also