AtomicBorrow

Struct AtomicBorrow 

Source
pub struct AtomicBorrow { /* private fields */ }
Expand description

An atomic reference counter.

Implementations§

Source§

impl AtomicBorrow

Source

pub const SHARED_MASK: usize = 9_223_372_036_854_775_807usize

The mask for the shared borrow count.

Source

pub const UNIQUE_MASK: usize = 9_223_372_036_854_775_808usize

The mask for the unique borrow bit.

Source

pub const fn new() -> Self

Creates a new AtomicBorrow.

Source

pub fn shared_count(&self) -> usize

Returns number of shared borrows.

Source

pub fn is_unique(&self) -> bool

Returns true if self is uniquely borrowed.

Source

pub fn is_borrowed(&self) -> bool

Returns true if self is borrowed in any way.

Source

pub fn borrow(&self) -> bool

Tries to acquire a shared reference.

Returns true if the reference was acquired.

Source

pub fn borrow_mut(&self) -> bool

Tries to acquire a unique reference.

Returns true if the reference was acquired.

Source

pub fn release(&self)

Releases a shared reference.

§Panics.
  • If self is not borrowed. Only with debug_assertions enabled.
  • If self is uniquely borrowed. Only with debug_assertions enabled.
Source

pub fn release_mut(&self)

Releases a unique reference.

§Panics.
  • If self is not uniquely borrowed. Only with debug_assertions enabled.
Source

pub fn spin_borrow(&self)

Spins until a shared reference can be acquired.

Source

pub fn spin_borrow_mut(&self)

Spins until a unique reference can be acquired.

Trait Implementations§

Source§

impl Debug for AtomicBorrow

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for AtomicBorrow

Source§

fn default() -> AtomicBorrow

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> 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.