| 2451 | } |
| 2452 | |
| 2453 | fn pollster_block_on<F: std::future::Future>(future: F) -> F::Output { |
| 2454 | use std::task::{Context, Poll, Wake, Waker}; |
| 2455 | use std::pin::Pin; |
| 2456 | use std::sync::Arc; |
| 2457 | struct NoopWaker; |
| 2458 | impl Wake for NoopWaker { fn wake(self: Arc<Self>) {} } |
| 2459 | let waker = Waker::from(Arc::new(NoopWaker)); |
| 2460 | let mut cx = Context::from_waker(&waker); |
| 2461 | let mut future = unsafe { Pin::new_unchecked(Box::new(future)) }; |
| 2462 | loop { |
| 2463 | match future.as_mut().poll(&mut cx) { |
| 2464 | Poll::Ready(result) => return result, |
| 2465 | Poll::Pending => std::thread::yield_now(), |
| 2466 | } |
| 2467 | } |
| 2468 | } |
| 2469 | |
| 2470 | |
| 2471 | |