dope-core 0.77.0

Owned native I/O and completion driver for dope
Documentation
use std::mem;

use dope_sys::io::reactor::event;

use crate::{
    driver::{
        self, life,
        schedule::{clock, state},
    },
    executor::drive::turn::modes,
};

mod sealed;
pub use sealed::core::Core;

pub(crate) struct Boot<'run, 'd, Report> {
    driver: &'run mut life::Lifecycle<'d, Report>,
    schedule: &'run mut state::Core<'d>,
}

impl<'run, 'd, Report: event::Report<Event = crate::Reported>> Boot<'run, 'd, Report> {
    pub(crate) fn try_new<Q>(
        core: &'run mut life::Core<'_, 'd, Q, Report>,
    ) -> Result<Self, life::Busy> {
        if core.pending.is_some() {
            return Err(life::Busy);
        }
        core.try_boot()?;
        let (_, driver, schedule) = core.split();
        Ok(Self { driver, schedule })
    }

    pub(crate) fn driver_ref(&self) -> driver::Reference<'d> {
        self.driver.driver_ref()
    }

    pub(crate) fn begin(&mut self, tick: clock::Sample) -> Core<'_, 'd, modes::Boot, Report> {
        Core {
            driver: &mut *self.driver,
            turn: self.schedule.begin_at(tick),
            mode: modes::Boot,
        }
    }
}

const _: () = {
    assert!(mem::size_of::<Boot<'_, '_, ()>>() == 2 * mem::size_of::<usize>());
    assert!(mem::align_of::<Boot<'_, '_, ()>>() == mem::align_of::<usize>());
};