use std::future::Future;
use std::time::Duration;
pub mod executor;
pub mod launcher;
pub mod runtime;
mod sys;
pub mod time;
cfg_select! {
target_os = "linux" => {
pub type DefaultBackend = dope_uring::UringBackend;
}
_ => {
pub type DefaultBackend = dope_kqueue::KqueueBackend;
}
}
pub type Driver = <DefaultBackend as dope_core::driver::Backend>::Driver;
pub type RuntimeCtx = executor::RuntimeCtx<DefaultBackend>;
pub type ExternalDispatch = dope_core::driver::ExternalDispatch<DefaultBackend>;
pub type JoinHandle<T> = executor::JoinHandle<T>;
#[inline(always)]
pub fn current() -> RuntimeCtx {
executor::current::<DefaultBackend>()
}
#[inline(always)]
pub fn spawn<F>(fut: F) -> JoinHandle<F::Output>
where
F: Future + 'static,
F::Output: 'static,
{
executor::spawn::<DefaultBackend, F>(fut)
}
#[inline(always)]
pub fn block_on<F: Future>(fut: F) -> F::Output {
executor::block_on::<DefaultBackend, F>(fut)
}
#[inline(always)]
pub fn install_external(aux: Option<ExternalDispatch>) -> Option<ExternalDispatch> {
executor::install_external::<DefaultBackend>(aux)
}
#[inline(always)]
pub async fn sleep(duration: Duration) -> std::io::Result<()> {
time::sleep::<DefaultBackend>(duration).await
}
#[inline(always)]
pub fn timeout<F: Future>(
duration: Duration,
fut: F,
) -> impl Future<Output = std::io::Result<F::Output>> {
time::timeout::<DefaultBackend, F>(duration, fut)
}