| 589 | type Output = TickResult; |
| 590 | |
| 591 | fn poll( |
| 592 | mut self: std::pin::Pin<&mut Self>, |
| 593 | cx: &mut std::task::Context<'_>, |
| 594 | ) -> std::task::Poll<Self::Output> { |
| 595 | let completed = self.completed; |
| 596 | if self.wakeup.poll_recv(cx).is_ready() { |
| 597 | return Poll::Ready(TickResult::Continue); |
| 598 | } |
| 599 | |
| 600 | if let Poll::Ready(opt) = self.rx.poll_recv(cx) { |
| 601 | return Poll::Ready(TickResult::Command(opt)); |
| 602 | } |
| 603 | |
| 604 | match self.rt.poll_event_loop(cx, Default::default()) { |
| 605 | Poll::Pending => Poll::Pending, |
| 606 | Poll::Ready(Ok(_)) => { |
| 607 | if completed { |
| 608 | Poll::Pending |
| 609 | } else { |
| 610 | Poll::Ready(TickResult::Completed) |
| 611 | } |
| 612 | } |
| 613 | Poll::Ready(Err(e)) => Poll::Ready(TickResult::VmError(e)), |
| 614 | } |
| 615 | } |
| 616 | } |
| 617 | |
| 618 | // future that drives the vm to completion, acquiring the isolate guard when needed |