o3 0.62.0

shared-nothing primitives
Documentation
pub mod group;
pub mod indexed;
pub mod links;
pub mod pool;
pub mod resident;
pub mod ring;
pub mod round;
pub mod tagged;

use indexed::{exact, fifo};

pub struct Sweep<'a, Q> {
    pub(in crate::depot) owner: &'a mut Q,
    pub(in crate::depot) remaining: usize,
}

impl<Q> Sweep<'_, Q> {
    pub fn len(&self) -> usize {
        self.remaining
    }

    pub fn is_empty(&self) -> bool {
        self.remaining == 0
    }

    pub(in crate::depot) fn take(&mut self) -> Option<&mut Q> {
        if self.remaining == 0 {
            return None;
        }
        self.remaining -= 1;
        Some(&mut *self.owner)
    }
}

impl<T: Copy + Eq, I: crate::depot::raw::Compact> Sweep<'_, fifo::List<T, I>> {
    pub fn pop_front(&mut self) -> Option<(exact::Entry<'_, T, I>, T)> {
        let owner = self.take()?;
        // SAFETY: admission retains every unvisited head; each loan changes only its own popped slot.
        let index = unsafe { owner.store.queue::<0>().chain().front_key() };
        let value = unsafe { owner.store.at(index.get()).take::<0, true>() };
        // SAFETY: this physical identity belongs to the retained compact domain.
        let index = unsafe { I::from_raw(index.raw()) };
        Some((exact::Entry { owner, index }, value))
    }
}