From c0189abb6369c6d909dd2a0ea3df851ff192feb2 Mon Sep 17 00:00:00 2001 From: zetanumbers Date: Thu, 24 Dec 2020 23:23:58 +0300 Subject: [PATCH] Add `poll_once` for `Runloop` --- src/runtime/runloop.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/runtime/runloop.rs b/src/runtime/runloop.rs index ee088c0f7..ae6ec5087 100644 --- a/src/runtime/runloop.rs +++ b/src/runtime/runloop.rs @@ -73,6 +73,16 @@ where self.inner.force() } + /// TODO description + pub fn poll_once(&mut self) -> Poll { + self.inner.poll_once(&mut self.root) + } + + /// TODO description + pub fn poll_once_with(&mut self, waker: Waker) -> Poll { + 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. @@ -98,6 +108,6 @@ where /// `poll_next`, always returning `Poll::Ready(Some(...))`. fn poll_next(self: Pin<&mut Self>, cx: &mut FutContext<'_>) -> Poll> { let this = self.get_mut(); - this.inner.poll_once_with(&mut this.root, cx.waker().clone()).map(Some) + this.poll_once_with(&mut this.root, cx.waker().clone()).map(Some) } }