expression

JoinSet shutdown: abort and drain

Abort tasks owned by the group and wait for their termination. Use normal joining for application results; shutdown discards these results and is not a graceful application protocol by itself. Tokio is an external dependency; see the proposed Cargo manifest. Expected stdout (not executed): true Common mistake: Confusing immediate cancellation with a graceful drain of business operations.

Formal Syntax & Structure

rust syntaxrust
group.shutdown().await

Working Example

Example Snippetrust
#[tokio::main(flavor = "current_thread")]async fn main() {    let mut group = tokio::task::JoinSet::<()>::new();    group.spawn(std::future::pending::<()>());    group.spawn(std::future::pending::<()>());    group.shutdown().await;    println!("{}", group.is_empty());}
Rust Reference