1use alloc::boxed::Box;
2use core::{future::Future, pin::Pin};
3
4pub type BoxFuture<'t, T = ()> = Pin<Box<dyn Future<Output = T> + Send + 't>>;
5pub type LocalBoxFuture<'t, T = ()> = Pin<Box<dyn Future<Output = T> + 't>>;
6
7pub fn yield_now() -> YieldNow {
10 YieldNow(false)
11}
12
13pub struct YieldNow(bool);
15
16impl Future for YieldNow {
17 type Output = ();
18 fn poll(mut self: Pin<&mut Self>, cx: &mut core::task::Context<'_>) -> core::task::Poll<()> {
19 if self.0 {
20 return core::task::Poll::Ready(());
21 }
22 self.0 = true;
23 cx.waker().wake_by_ref();
24 core::task::Poll::Pending
25 }
26}