MCPcopy Create free account
hub / github.com/Bloom-Engine/engine / pollster_block_on

Function pollster_block_on

native/linux/src/lib.rs:2453–2468  ·  view source on GitHub ↗
(future: F)

Source from the content-addressed store, hash-verified

2451}
2452
2453fn 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

Callers 1

bloom_init_windowFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected