use std::{marker, num};
use o3::base::marker::ThreadBound;
use crate::driver::schedule::clock::timer::heap;
#[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>());
};