wasmtime/runtime/vm/
async_yield.rs1use core::{
2 future::Future,
3 pin::Pin,
4 task::{Context, Poll},
5};
6
7#[derive(Default)]
9pub struct Yield {
10 yielded: bool,
11}
12
13impl Yield {
14 pub fn new() -> Self {
16 Self::default()
17 }
18}
19
20impl Future for Yield {
21 type Output = ();
22
23 fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<()> {
24 if self.yielded {
25 Poll::Ready(())
26 } else {
27 self.yielded = true;
31 cx.waker().wake_by_ref();
32 Poll::Pending
33 }
34 }
35}