pub struct EpochArray { /* private fields */ }
Expand description
An epoch counter array. This can be used to check if an index is current by comparing its entry in the epoch array to the current epoch. To unmark all values, the current epoch can be increased in O(1). Only overflows have to be handled by resetting all epoch counters.
Implementations
sourceimpl EpochArray
impl EpochArray
sourcepub fn new(len: usize) -> Self
pub fn new(len: usize) -> Self
Create a new epoch array of given length where all values are outdated.
sourcepub fn update(&mut self, index: usize)
pub fn update(&mut self, index: usize)
Set the given index as current.
Safety: Undefined behaviour if the index is out of bounds of the epoch array.
sourcepub fn get(&self, index: usize) -> bool
pub fn get(&self, index: usize) -> bool
Returns true if the given index is current, and false otherwise.
sourcepub fn get_and_update(&mut self, index: usize) -> bool
pub fn get_and_update(&mut self, index: usize) -> bool
Updates the given index and returns true if the given index was current before, and false otherwise.
Auto Trait Implementations
impl RefUnwindSafe for EpochArray
impl Send for EpochArray
impl Sync for EpochArray
impl Unpin for EpochArray
impl UnwindSafe for EpochArray
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more