dope-core 0.77.0

Owned native I/O and completion driver for dope
Documentation
use std::{marker, num};

use o3::base::marker::ThreadBound;

use crate::driver::schedule::clock::timer::heap;

/// Linear ownership of one resident slot within its owning store brand.
#[repr(transparent)]
pub struct Lease<'id, Tag = ()> {
    slot: num::NonZero<u32>,
    thread: ThreadBound,
    brand: marker::PhantomData<fn(&'id Tag) -> &'id Tag>,
}

impl<Tag> Lease<'_, Tag> {
    pub(super) fn new(slot: num::NonZero<u32>) -> Self {
        Self {
            slot,
            thread: ThreadBound::NEW,
            brand: marker::PhantomData,
        }
    }

    pub(super) const fn slot(&self) -> heap::Slot {
        heap::Slot::from_one(self.slot)
    }
}

const _: () = {
    assert!(std::mem::size_of::<Lease<'static>>() == std::mem::size_of::<u32>());
    assert!(std::mem::align_of::<Lease<'static>>() == std::mem::align_of::<u32>());
    assert!(std::mem::size_of::<Option<Lease<'static>>>() == std::mem::size_of::<u32>());
};