pub struct LifetimeStateAccess<'a> { /* private fields */ }Expand description
Guard over the internal spin lock of a LifetimeState, through which
the borrow and access counters are updated.
Releases the lock on drop. Hold it only long enough to check a condition and update the counters: while it is taken, every other handle to the same lifetime is refused or spinning.
Implementations§
Source§impl LifetimeStateAccess<'_>
impl LifetimeStateAccess<'_>
Sourcepub fn state(&self) -> &LifetimeState
pub fn state(&self) -> &LifetimeState
Returns the locked state.
Sourcepub fn unlock(&mut self, value: bool)
pub fn unlock(&mut self, value: bool)
Chooses whether dropping this guard releases the spin lock.
With false the lock stays taken until something releases it through
LifetimeState::lock_unchecked. A held lock blocks every other handle
to the same lifetime.
Sourcepub fn acquire_reader(&mut self)
pub fn acquire_reader(&mut self)
Counts one more shared borrow.
Sourcepub fn release_reader(&mut self)
pub fn release_reader(&mut self)
Counts one shared borrow less, saturating at zero.
Sourcepub fn acquire_writer(&mut self) -> usize
pub fn acquire_writer(&mut self) -> usize
Counts one more nested mutable borrow and returns its new depth.
The depth has to be given back to LifetimeStateAccess::release_writer.
Sourcepub fn release_writer(&mut self, id: usize)
pub fn release_writer(&mut self, id: usize)
Drops the mutable borrow at depth id, along with anything nested
inside it. Does nothing when id is deeper than the current depth.
Sourcepub fn acquire_read_access(&mut self)
pub fn acquire_read_access(&mut self)
Counts one more live read guard.
Sourcepub fn release_read_access(&mut self)
pub fn release_read_access(&mut self)
Counts one live read guard less, saturating at zero.
Sourcepub fn acquire_write_access(&mut self)
pub fn acquire_write_access(&mut self)
Marks a write guard as live, excluding every other access.
Sourcepub fn release_write_access(&mut self)
pub fn release_write_access(&mut self)
Marks the write guard as gone.