pub struct LifetimeState { /* private fields */ }Expand description
Cloneable strong handle to the counters behind a Lifetime.
Mostly an implementation detail of this module. Keeping one alive keeps the counters alive, but it does not itself claim a borrow or an access.
Implementations§
Source§impl LifetimeState
impl LifetimeState
Sourcepub fn can_write(&self, id: usize) -> bool
pub fn can_write(&self, id: usize) -> bool
Returns true when there are no readers and id is the current writer
depth.
Pass 0 to ask for a top level mutable borrow, or the depth of an
existing LifetimeRefMut to ask for a nested reborrow.
Sourcepub fn readers_count(&self) -> usize
pub fn readers_count(&self) -> usize
Returns how many LifetimeRef handles are out.
Sourcepub fn writer_depth(&self) -> usize
pub fn writer_depth(&self) -> usize
Returns how deeply mutable borrows are nested, 0 when none is out.
Sourcepub fn is_read_accessible(&self) -> bool
pub fn is_read_accessible(&self) -> bool
Returns true when no write access guard is live.
Sourcepub fn is_write_accessible(&self) -> bool
pub fn is_write_accessible(&self) -> bool
Returns true when no access guard of any kind is live.
Sourcepub fn is_locked(&self) -> bool
pub fn is_locked(&self) -> bool
Returns true while another thread holds the internal spin lock.
Sourcepub fn try_lock(&self) -> Option<LifetimeStateAccess<'_>>
pub fn try_lock(&self) -> Option<LifetimeStateAccess<'_>>
Takes the internal spin lock, or returns None when it is taken.
Sourcepub fn lock(&self) -> LifetimeStateAccess<'_>
pub fn lock(&self) -> LifetimeStateAccess<'_>
Takes the internal spin lock, spinning until it is free.
Sourcepub unsafe fn lock_unchecked(&self) -> LifetimeStateAccess<'_>
pub unsafe fn lock_unchecked(&self) -> LifetimeStateAccess<'_>
Builds a lock guard without taking the lock.
§Safety
No other thread must update the counters while this guard lives. If one
does, the read-modify-write pairs in LifetimeStateAccess can lose an
update.
Sourcepub unsafe fn update_tag(&self, tag: &Lifetime)
pub unsafe fn update_tag(&self, tag: &Lifetime)
Sourcepub unsafe fn invalidate_tag(&self)
pub unsafe fn invalidate_tag(&self)
Clears the tag, so every handle taken so far stops upgrading.
§Safety
Callers holding handles will see them go dead. Use through
Lifetime::invalidate rather than directly.
Sourcepub fn downgrade(&self) -> LifetimeWeakState
pub fn downgrade(&self) -> LifetimeWeakState
Takes a weak handle that remembers the current tag.
Trait Implementations§
Source§impl Clone for LifetimeState
impl Clone for LifetimeState
Source§fn clone(&self) -> LifetimeState
fn clone(&self) -> LifetimeState
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more