async: split async_engine into multiple files
This commit is contained in:
parent
57e8077942
commit
87a90a8ae4
7 changed files with 706 additions and 717 deletions
27
src/async_engine/ae_yield.rs
Normal file
27
src/async_engine/ae_yield.rs
Normal 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
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue