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
#[allow(unused_macros)]
macro_rules! syscall {
    ($fn: ident ( $($arg: expr),* $(,)* ) ) => {{
        let res = unsafe { libc::$fn($($arg, )*) };
        if res == -1 {
            Err(std::io::Error::last_os_error())
        } else {
            Ok(res)
        }
    }};
}

mod buffer;
pub(crate) mod driver;
mod local_executor;
pub mod net;
pub mod runtime;
mod socket;
pub mod time;
mod waker_fn;

use std::future::Future;

pub use local_executor::spawn_local;
use runtime::Runtime;

thread_local! {
    static RUNTIME: Runtime = Runtime::new().expect("new runtime fail");
}

pub fn block_on<F>(future: F) -> F::Output
where
    F: Future,
{
    RUNTIME.with(|runtime| runtime.block_on(future))
}