1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// use core::hint::spin_loop;
// use core::ptr;
// use core::task::{Context, Poll, RawWaker, RawWakerVTable, Waker};
// use pasts::prelude::*;
// pub fn init_exeutor() {
// unsafe {
// EXECUTOR = Some(Executor::default());
// }
// }
// fn executor() -> &'static Executor {
// unsafe { EXECUTOR.as_ref().unwrap() }
// }
// pub fn block_on(f: impl Future<Output = ()> + 'static) {
// Executor::default().block_on(f);
// }
// pub fn spawn_boxed(f: impl Future<Output = ()> + 'static) {
// executor().spawn_boxed(f)
// }
// static VTABLE: RawWakerVTable = RawWakerVTable::new(
// |_| RawWaker::new(ptr::null(), &VTABLE),
// |_| {},
// |_| {},
// |_| {},
// );
// pub fn block_on<F: Future>(mut fut: F) -> F::Output {
// // safety: we don't move the future after this line.
// let mut fut = unsafe { Pin::new_unchecked(&mut fut) };
// let raw_waker = RawWaker::new(ptr::null(), &VTABLE);
// let waker = unsafe { Waker::from_raw(raw_waker) };
// let mut cx = Context::from_waker(&waker);
// loop {
// if let Poll::Ready(res) = fut.as_mut().poll(&mut cx) {
// return res;
// }
// spin_loop();
// }
// }