o3 0.61.0

shared-nothing primitives
Documentation
use crate::depot::{
    array::Index,
    queue::{
        group::{self, capacity, vacant},
        indexed::slab,
    },
};

/// N slots admitted before any value is accepted.
pub struct Batch<'a, V, const LANES: usize, const N: usize> {
    pub(super) ledger: &'a mut group::Ledger<V, LANES>,
}

impl<'a, V, const LANES: usize, const N: usize> Batch<'a, V, LANES, N> {
    pub fn new(ledger: &'a mut group::Ledger<V, LANES>) -> Result<Self, group::Error<LANES>> {
        Slots::<_, LANES, N>::new(&mut ledger.entries).map_err(group::Error::Entries)?;
        Ok(Self { ledger })
    }

    /// Resolves every owner before accepting any value.
    pub fn bind(
        self,
        owners: [(Index<LANES>, u64); N],
    ) -> Result<vacant::Entry<'a, V, LANES, N>, group::Error<LANES>> {
        vacant::Entry::new(self, owners)
    }
}

pub(super) type Slots<'a, V, const LANES: usize, const N: usize> = slab::Batch<
    'a,
    group::Entry<V>,
    group::EntryTag,
    LANES,
    N,
    { u32::MAX },
    capacity::Count<LANES>,
>;