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
48
49
50
51
#[macro_export]
macro_rules! pin_mut {
($($x:ident),* $(,)?) => { $(
let mut $x = $x;
#[allow(unused_mut)]
let mut $x = unsafe {
std::pin::Pin::new_unchecked(&mut $x)
};
)* }
}
#[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)
}
}};
}
#[macro_export]
macro_rules! ready {
($e:expr $(,)?) => {
match $e {
std::task::Poll::Ready(t) => t,
std::task::Poll::Pending => return core::task::Poll::Pending,
}
};
}
use std::future::Future;
mod driver;
mod local_executor;
pub mod net;
pub mod runtime;
pub mod time;
mod waker_fn;
pub use async_task::Task;
pub use futures_util::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt};
pub fn spawn_local<T: 'static>(future: impl Future<Output = T> + 'static) -> Task<T> {
local_executor::spawn_local(future)
}