use std::cell::Cell;
use crate::depot::{
self,
queue::round::{
self,
values::{Head, Snapshot},
},
};
pub struct Group<'a, T: Copy, const G: usize, const N: usize = 0>(
pub(super) round::Group<'a, Cell<Option<T>>, G, N>,
);
impl<'a, T: Copy, const G: usize, const N: usize> Group<'a, T, G, N> {
pub fn active(&self) -> Option<(Snapshot<'a, T, G, round::Turn, N>, T)> {
let head = Head(self.0.select()?);
let value = head.get();
Some((
Snapshot(round::Snapshot::new(head.0.owner, head.0.position)),
value,
))
}
pub fn next(&self) -> Option<T> {
let head = Head(self.0.select()?);
Some(Head::consume(unsafe { depot::raw::Proof::new(head) }))
}
}