Skip to main content

LifetimeState

Struct LifetimeState 

Source
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

Source

pub fn can_read(&self) -> bool

Returns true when no mutable borrow is out.

Source

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.

Source

pub fn readers_count(&self) -> usize

Returns how many LifetimeRef handles are out.

Source

pub fn writer_depth(&self) -> usize

Returns how deeply mutable borrows are nested, 0 when none is out.

Source

pub fn is_read_accessible(&self) -> bool

Returns true when no write access guard is live.

Source

pub fn is_write_accessible(&self) -> bool

Returns true when no access guard of any kind is live.

Source

pub fn is_in_use(&self) -> bool

Returns true while any access guard is live.

Source

pub fn is_locked(&self) -> bool

Returns true while another thread holds the internal spin lock.

Source

pub fn try_lock(&self) -> Option<LifetimeStateAccess<'_>>

Takes the internal spin lock, or returns None when it is taken.

Source

pub fn lock(&self) -> LifetimeStateAccess<'_>

Takes the internal spin lock, spinning until it is free.

Source

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.

Source

pub unsafe fn update_tag(&self, tag: &Lifetime)

Stamps the address of the owning Lifetime as the current tag.

§Safety

tag must be the Lifetime that owns this state. Passing another one makes stale handles look valid again.

Source

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.

Source

pub fn tag(&self) -> usize

Returns the current tag, or 0 when the state was invalidated.

Source

pub fn downgrade(&self) -> LifetimeWeakState

Takes a weak handle that remembers the current tag.

Trait Implementations§

Source§

impl Clone for LifetimeState

Source§

fn clone(&self) -> LifetimeState

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for LifetimeState

Source§

fn default() -> LifetimeState

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Finalize for T

Source§

unsafe fn finalize_raw(data: *mut ())

Drops the value stored at data in place. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Initialize for T
where T: Default,

Source§

fn initialize() -> T

Returns the initial value of this type.
Source§

unsafe fn initialize_raw(data: *mut ())

Writes the initial value into already allocated memory. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.