1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
//! Run this example to see how taskdumps appear with multiple tasks.
#[tokio::main(flavor = "current_thread")]
async fn main() {
tokio::select! {
// run the following branches in order of their appearance
biased;
// spawn task #1
_ = tokio::spawn(foo()) => { unreachable!() }
// spawn task #2
_ = tokio::spawn(foo()) => { unreachable!() }
// print the running tasks
_ = tokio::spawn(async {}) => {
println!("{}", async_backtrace::taskdump_tree(true));
}
};
}
#[async_backtrace::framed]
async fn foo() {
bar().await;
}
#[async_backtrace::framed]
async fn bar() {
baz().await;
}
#[async_backtrace::framed]
async fn baz() {
std::future::pending::<()>().await
}
|