Struct RwLock

pub struct RwLock { pub(in ::sys::sync::rwlock::futex) state: Atomic<u32>, pub(in ::sys::sync::rwlock::futex) writer_notify: Atomic<u32> }

Fields

state: Atomic<u32>
writer_notify: Atomic<u32>

Implementations

impl RwLock

const fn new() -> Self
fn try_read(&self) -> bool
fn read(&self)
unsafe fn read_unlock(&self)

Safety

The RwLock must be read-locked (N readers) in order to call this.

fn read_contended(&self)
fn try_write(&self) -> bool
fn write(&self)
unsafe fn write_unlock(&self)

Safety

The RwLock must be write-locked (single writer) in order to call this.

unsafe fn downgrade(&self)

Safety

The RwLock must be write-locked (single writer) in order to call this.

fn write_contended(&self)
fn wake_writer_or_readers(&self, state: u32)

Wakes up waiting threads after unlocking.

If both are waiting, this will wake up only one writer, but will fall back to waking up readers if there was no writer to wake up.

fn wake_writer(&self) -> bool

This wakes one writer and returns true if we woke up a writer that was blocked on futex_wait.

If this returns false, it might still be the case that we notified a writer that was about to go to sleep.

fn spin_until(&self, f: impl Fn(u32) -> bool) -> u32

Spin for a while, but stop directly at the given condition.

fn spin_write(&self) -> u32
fn spin_read(&self) -> u32

Auto Trait Implementations

impl !Freeze for RwLock

impl RefUnwindSafe for RwLock

impl Send for RwLock

impl Sync for RwLock

impl Unpin for RwLock

impl UnsafeUnpin for RwLock

impl UnwindSafe for RwLock

Blanket Implementations

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

fn type_id(&self) -> TypeId

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

fn borrow(&self) -> &T

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

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

impl<T> From<T> for RwLock

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> SizeHint for RwLock where T: ?Sized,

fn lower_bound(&self) -> usize
fn upper_bound(&self) -> Option<usize>

impl<T> SizedTypeProperties for RwLock

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

fn into(self) -> U

Calls U::from(self).

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

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

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

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

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