pub use iceoryx2_bb_lock_free::mpmc::counting_bit_set::RelocatableCountingBitSet;
use iceoryx2_log::fail;
use crate::event::{
EventId,
event_state::{EventActivation, EventState, EventStateActivateError},
};
impl EventState for RelocatableCountingBitSet {
fn max_event_count(&self) -> u64 {
Self::max_count()
}
fn max_event_id(&self) -> EventId {
EventId::new(self.capacity().saturating_sub(1))
}
fn activate(&self, event_id: EventId) -> Result<(), EventStateActivateError> {
if self.max_event_id() < event_id {
fail!(from self, with EventStateActivateError::EventIdOutOfBounds,
"Unable to activate {event_id:?} since it is out of bounds (max = {:?}).", self.max_event_id());
}
self.set(event_id.as_value());
Ok(())
}
fn drain<F: FnMut(EventActivation)>(&self, callback: &mut F) -> u64 {
let mut counter = 0;
self.reset_all(|bit_state| {
counter += bit_state.count();
callback(EventActivation {
id: EventId::new(bit_state.bit()),
count: bit_state.count(),
});
});
counter
}
}