pub(crate) struct SeqLock {
    state: AtomicUsize,
}Expand description
A simple stamped lock.
Fields§
§state: AtomicUsizeThe current state of the lock.
All bits except the least significant one hold the current stamp. When locked, the state equals 1 and doesn’t contain a valid stamp.
Implementations§
Source§impl SeqLock
 
impl SeqLock
pub(crate) const fn new() -> Self
Sourcepub(crate) fn optimistic_read(&self) -> Option<usize>
 
pub(crate) fn optimistic_read(&self) -> Option<usize>
If not locked, returns the current stamp.
This method should be called before optimistic reads.
Sourcepub(crate) fn validate_read(&self, stamp: usize) -> bool
 
pub(crate) fn validate_read(&self, stamp: usize) -> bool
Returns true if the current stamp is equal to stamp.
This method should be called after optimistic reads to check whether they are valid. The
argument stamp should correspond to the one returned by method optimistic_read.
Sourcepub(crate) fn write(&'static self) -> SeqLockWriteGuard
 
pub(crate) fn write(&'static self) -> SeqLockWriteGuard
Grabs the lock for writing.
Auto Trait Implementations§
impl !Freeze for SeqLock
impl RefUnwindSafe for SeqLock
impl Send for SeqLock
impl Sync for SeqLock
impl Unpin for SeqLock
impl UnwindSafe for SeqLock
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