use std::mem;
use crate::depot::queue::round;
#[derive(Debug)]
pub struct Place;
impl<'a, T, const G: usize, const N: usize> round::Snapshot<&'a round::Lanes<T, G, N>, Place> {
pub fn slot(&self) -> round::Slot<'a, T, G, N> {
round::Slot {
owner: self.owner,
index: self.position.index,
}
}
pub fn set(&self) -> bool {
let lane = self.slot().linked_lane();
if lane == Some(self.position.lane) {
return false;
}
let round::Lanes { block, groups } = self.owner;
unsafe { round::lanes::push_from(block, groups, self.position, lane) };
true
}
pub fn push(&self) {
let lane = self.slot().linked_lane();
let round::Lanes { block, groups } = self.owner;
unsafe { round::lanes::push_from(block, groups, self.position, lane) };
}
}
const _: () = {
assert!(
mem::size_of::<round::Snapshot<&'static round::Lanes<(), 1>, Place>>()
== 2 * mem::size_of::<usize>()
);
assert!(
mem::size_of::<Option<round::Snapshot<&'static round::Lanes<(), 1>, Place>>>()
== 2 * mem::size_of::<usize>()
);
};