1use std::{thread, time::Duration};
2
3use microasync::{join, sync};
4use microasync_rt::defer;
5
6fn main() {
7 println!(
8 "{}",
9 sync(join!(test(), async {
10 is_alive().await;
11 "".to_owned()
12 }))[0]
13 );
14}
15
16async fn is_alive() {
17 println!(
18 "The runtime is NOT blocked by the test() function: This future runs *after* the poll \
19 to the test() function, so if this runs before test() is done, that means test() returned \
20 Poll::Pending and is not blocking."
21 );
22}
23
24async fn test() -> String {
25 defer(
26 |(s,)| {
27 thread::sleep(Duration::from_millis(2000));
28 s + "world"
29 },
30 ("Hello, ".to_owned(),),
31 )
32 .await
33}