dope-runtime 0.2.0

Thin io_uring adaptor with "Manifolds"
Documentation
use dope_core::driver::{
    Completion, CompletionBackend, CompletionRouter, DriverOps, ExternalDispatch, PoolDriver,
};

pub fn install_external<B: CompletionBackend>(
    aux: Option<ExternalDispatch<B>>,
) -> Option<ExternalDispatch<B>> {
    B::install_external(aux)
}

#[inline(always)]
pub(super) fn current_external<B: CompletionBackend>() -> Option<ExternalDispatch<B>> {
    B::current_external()
}

pub(super) struct ExternalRouter<B: CompletionBackend> {
    pub(super) aux: Option<ExternalDispatch<B>>,
}

impl<B: PoolDriver> CompletionRouter<B> for ExternalRouter<B> {
    #[inline(always)]
    fn on_complete(&mut self, driver: &mut B::Driver, ev: Completion<B>) {
        if let Some(a) = self.aux {
            unsafe { (a.route)(a.state, driver, ev) };
        } else if let Some(b) = ev.buffer_select() {
            use dope_core::driver::ProvidedRingOps;
            driver.provided_ring().defer(b);
        }
    }
}