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
impl RawRwLock
pub(super) const fn new() -> Self
pub(super) fn read(&self) -> RawRead<'_>
Sourcepub(super) fn try_upgradable_read(&self) -> bool
pub(super) fn try_upgradable_read(&self) -> bool
Returns true
iff an upgradable read lock was successfully acquired.
pub(super) fn upgradable_read(&self) -> RawUpgradableRead<'_>
Sourcepub(super) fn try_write(&self) -> bool
pub(super) fn try_write(&self) -> bool
Returns true
iff a write lock was successfully acquired.
pub(super) fn write(&self) -> RawWrite<'_>
Sourcepub(super) unsafe fn try_upgrade(&self) -> bool
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.
Sourcepub(super) unsafe fn upgrade(&self) -> RawUpgrade<'_>
pub(super) unsafe fn upgrade(&self) -> RawUpgrade<'_>
§Safety
Caller must hold an upgradable read lock. This will upgrade it to a write lock.
Sourcepub(super) unsafe fn downgrade_upgradable_read(&self)
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.
Sourcepub(super) unsafe fn downgrade_write(&self)
pub(super) unsafe fn downgrade_write(&self)
§Safety
Caller must hold a write lock. This will downgrade it to a read lock.
Sourcepub(super) unsafe fn downgrade_to_upgradable(&self)
pub(super) unsafe fn downgrade_to_upgradable(&self)
§Safety
Caller must hold a write lock. This will downgrade it to an upgradable read lock.
Sourcepub(super) unsafe fn read_unlock(&self)
pub(super) unsafe fn read_unlock(&self)
§Safety
Caller must hold a read lock . This will unlock that lock.
Sourcepub(super) unsafe fn upgradable_read_unlock(&self)
pub(super) unsafe fn upgradable_read_unlock(&self)
§Safety
Caller must hold an upgradable read lock. This will unlock that lock.
Sourcepub(super) unsafe fn write_unlock(&self)
pub(super) unsafe fn write_unlock(&self)
§Safety
Caller must hold a write lock. This will unlock that lock.