Struct RawRwLock

Source
pub(super) struct RawRwLock {
    mutex: Mutex<()>,
    no_readers: Event,
    no_writer: Event,
    state: AtomicUsize,
}
Expand description

A “raw” RwLock that doesn’t hold any data.

Fields§

§mutex: Mutex<()>

Acquired by the writer.

§no_readers: Event

Event triggered when the last reader is dropped.

§no_writer: Event

Event triggered when the writer is dropped.

§state: AtomicUsize

Current state of the lock.

The least significant bit (WRITER_BIT) is set to 1 when a writer is holding the lock or trying to acquire it.

The upper bits contain the number of currently active readers. Each active reader increments the state by ONE_READER.

Implementations§

Source§

impl RawRwLock

Source

pub(super) const fn new() -> Self

Source

pub(super) fn try_read(&self) -> bool

Returns true iff a read lock was successfully acquired.

Source

pub(super) fn read(&self) -> RawRead<'_>

Source

pub(super) fn try_upgradable_read(&self) -> bool

Returns true iff an upgradable read lock was successfully acquired.

Source

pub(super) fn upgradable_read(&self) -> RawUpgradableRead<'_>

Source

pub(super) fn try_write(&self) -> bool

Returns true iff a write lock was successfully acquired.

Source

pub(super) fn write(&self) -> RawWrite<'_>

Source

pub(super) unsafe fn try_upgrade(&self) -> bool

Returns true iff a the upgradable read lock was successfully upgraded to a write lock.

§Safety

Caller must hold an upgradable read lock. This will attempt to upgrade it to a write lock.

Source

pub(super) unsafe fn upgrade(&self) -> RawUpgrade<'_>

§Safety

Caller must hold an upgradable read lock. This will upgrade it to a write lock.

Source

pub(super) unsafe fn downgrade_upgradable_read(&self)

§Safety

Caller must hold an upgradable read lock. This will downgrade it to a standard read lock.

Source

pub(super) unsafe fn downgrade_write(&self)

§Safety

Caller must hold a write lock. This will downgrade it to a read lock.

Source

pub(super) unsafe fn downgrade_to_upgradable(&self)

§Safety

Caller must hold a write lock. This will downgrade it to an upgradable read lock.

Source

pub(super) unsafe fn read_unlock(&self)

§Safety

Caller must hold a read lock . This will unlock that lock.

Source

pub(super) unsafe fn upgradable_read_unlock(&self)

§Safety

Caller must hold an upgradable read lock. This will unlock that lock.

Source

pub(super) unsafe fn write_unlock(&self)

§Safety

Caller must hold a write lock. This will unlock that lock.

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.