#![cfg(feature = "tokio")]
use std::time::Duration;
use futures::future::pending;
use tokio::time::sleep;
use crate::{Config, InstrumentAwait, Registry};
#[tokio::test]
async fn main() {
let registry = Registry::new(Config::default());
tokio::spawn(registry.register((), "root").instrument(async {
crate::spawn_anonymous("child", async {
crate::spawn_anonymous("grandson", async {
pending::<()>().await;
})
.instrument_await("wait for grandson")
.await
.unwrap()
})
.instrument_await("wait for child")
.await
.unwrap()
}));
sleep(Duration::from_secs(1)).await;
assert_eq!(registry.collect::<()>().len(), 1);
assert_eq!(registry.collect_anonymous().len(), 2);
assert_eq!(registry.collect_all().len(), 3);
}