use async_wakers::RemoteWaker; #[tokio::test] async fn works() { use std::future::Future; use std::pin::Pin; use std::task::{Context, Poll}; use std::time::Duration; use tokio::task; use tokio::time; struct WorksFut { waker: &'static RemoteWaker, } impl Future for WorksFut { type Output = bool; fn poll(self: Pin<&mut Self>, ctx: &mut Context) -> Poll { if self.waker.is_notified() { Poll::Ready(true) } else { self.waker.update_waker(ctx.waker().clone()); Poll::Pending } } } static WAKER: RemoteWaker = RemoteWaker::empty(); assert_eq!(WAKER.is_notified(), false); assert_eq!(WAKER.is_notifiable(), false); let task = task::spawn(time::timeout( Duration::from_secs(2), WorksFut { waker: &WAKER, }, )); while !WAKER.is_notifiable() { time::delay_for(Duration::from_millis(100)).await; } assert_eq!(WAKER.is_notified(), false); assert_eq!(WAKER.is_notifiable(), true); WAKER.notify(); assert!(task.await.unwrap().unwrap()); assert_eq!(WAKER.is_notified(), true); assert_eq!(WAKER.is_notifiable(), false); }