use crate::depot::{
array::Index,
queue::{
group::{self, capacity, vacant},
indexed::slab,
},
};
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 })
}
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>,
>;