Struct crossbeam_utils::atomic::seq_lock::SeqLock
source · pub(crate) struct SeqLock {
state: AtomicUsize,
}
Expand description
A simple stamped lock.
Fields§
§state: AtomicUsize
The 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