pub struct FenceGuard { /* private fields */ }Expand description
A stateful epoch checker that rejects operations with stale epochs.
Holds the “current” epoch and provides check() / advance() methods.
Typical use: place a FenceGuard in front of a resource and call check()
on every incoming operation’s epoch before allowing it through.
Implementations§
Source§impl FenceGuard
impl FenceGuard
Sourcepub fn new(expected: FenceEpoch) -> Self
pub fn new(expected: FenceEpoch) -> Self
Create a guard expecting the given epoch.
Sourcepub fn check(&self, incoming: FenceEpoch) -> Result<(), StaleEpochError>
pub fn check(&self, incoming: FenceEpoch) -> Result<(), StaleEpochError>
Check that incoming is not stale. Returns Ok(()) if incoming
is equal to or newer than the expected epoch. Returns
Err(StaleEpochError) if incoming is behind.
Sourcepub fn advance(&mut self) -> FenceEpoch
pub fn advance(&mut self) -> FenceEpoch
Bump the expected epoch by one and return the new epoch.
Trait Implementations§
Source§impl Clone for FenceGuard
impl Clone for FenceGuard
Source§fn clone(&self) -> FenceGuard
fn clone(&self) -> FenceGuard
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for FenceGuard
impl RefUnwindSafe for FenceGuard
impl Send for FenceGuard
impl Sync for FenceGuard
impl Unpin for FenceGuard
impl UnwindSafe for FenceGuard
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more