Skip to main content

LifetimeStateAccess

Struct LifetimeStateAccess 

Source
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<'_>

Source

pub fn state(&self) -> &LifetimeState

Returns the locked state.

Source

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.

Source

pub fn acquire_reader(&mut self)

Counts one more shared borrow.

Source

pub fn release_reader(&mut self)

Counts one shared borrow less, saturating at zero.

Source

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.

Source

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.

Source

pub fn acquire_read_access(&mut self)

Counts one more live read guard.

Source

pub fn release_read_access(&mut self)

Counts one live read guard less, saturating at zero.

Source

pub fn acquire_write_access(&mut self)

Marks a write guard as live, excluding every other access.

Source

pub fn release_write_access(&mut self)

Marks the write guard as gone.

Trait Implementations§

Source§

impl Drop for LifetimeStateAccess<'_>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. 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> 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, 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, 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.