1use std::{future::poll_fn, task::Poll, thread};
2
3use winmsg_executor::block_on;
4
5async fn poll_n_times(mut n_poll: usize) {
6 poll_fn(|cx| {
7 println!("n_poll={n_poll}");
8 if n_poll == 0 {
9 Poll::Ready(())
10 } else {
11 n_poll -= 1;
12 cx.waker().wake_by_ref();
13 Poll::Pending
14 }
15 })
16 .await;
17}
18
19fn main() {
20 thread::spawn(|| {
21 println!("thread hello");
22 block_on(async {
23 println!("thread async hello");
24 poll_n_times(3).await;
25 println!("thread async bye");
26 });
27 println!("thread bye");
28 });
29
30 println!("main hello");
31 block_on(async {
32 println!("main async hello");
33 poll_n_times(3).await;
34 println!("main async bye");
35 });
36 println!("main bye");
37}