Skip to content

Commit

Permalink
Add poll_once for Runloop
Browse files Browse the repository at this point in the history
  • Loading branch information
zetanumbers committed Dec 25, 2020
1 parent 085f17d commit 1919a88
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/runtime/runloop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,16 @@ where
self.inner.force()
}

/// TODO description
pub fn poll_once(&mut self) -> Poll<Out> {
self.inner.poll_once(&mut self.root)
}

/// TODO description
pub fn poll_once_with(&mut self, waker: Waker) -> Poll<Out> {
self.inner.poll_once_with(&mut self.root, waker)
}

/// Poll this runtime without exiting. Discards any value returned from the
/// root function. The future yields in between revisions and is woken on
/// state changes.
Expand All @@ -98,6 +108,6 @@ where
/// `poll_next`, always returning `Poll::Ready(Some(...))`.
fn poll_next(self: Pin<&mut Self>, cx: &mut FutContext<'_>) -> Poll<Option<Self::Item>> {
let this = self.get_mut();
this.inner.poll_once_with(&mut this.root, cx.waker().clone()).map(Some)
this.poll_once_with(cx.waker().clone()).map(Some)
}
}

0 comments on commit 1919a88

Please sign in to comment.