flake/runtime/next_frame.rs
1use std::{future::Future, pin::Pin, task::{Context, Poll}};
2
3pub struct NextFrame(bool);
4
5pub fn next_frame() -> NextFrame {
6 NextFrame(false)
7}
8
9impl Future for NextFrame {
10 type Output = ();
11
12 fn poll(mut self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<()> {
13 if self.0 {
14 Poll::Ready(())
15 } else {
16 self.0 = true;
17 Poll::Pending
18 }
19 }
20}