1
0
Fork 0
forked from wry/wry

async: split async_engine into multiple files

This commit is contained in:
Julian Orth 2022-05-12 16:10:22 +02:00
parent 57e8077942
commit 87a90a8ae4
7 changed files with 706 additions and 717 deletions

View file

@ -0,0 +1,27 @@
use {
crate::async_engine::ae_queue::DispatchQueue,
std::{
future::Future,
pin::Pin,
rc::Rc,
task::{Context, Poll},
},
};
pub struct Yield {
pub(super) iteration: u64,
pub(super) queue: Rc<DispatchQueue>,
}
impl Future for Yield {
type Output = ();
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
if self.queue.iteration() > self.iteration {
Poll::Ready(())
} else {
self.queue.push_yield(cx.waker().clone());
Poll::Pending
}
}
}