Struct RawSharedMutex

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

A raw lock providing both shared read locks and exclusive write locks.

Used as a raw building block for other synchronization primitives. Most users should just use SharedMutex<T>, which takes care of tieing the lock to some data.

Implementations§

Source§

impl RawSharedMutex

Source

pub fn new() -> RawSharedMutex

Create a new RawSharedMutex

Source

pub fn is(&self, other: &Self) -> bool

Checks if this mutex and the other are the same mutex.

If is returns true, the two references point to the same mutex, and they may be used interchangeably.

Source

pub fn read(&self)

Acquire a shared read lock.

Blocks until a read lock can be acquired. The lock can be released by calling unlock_read.

Source

pub fn try_read(&self) -> bool

Attempt to acquire a shared read lock without blocking.

Returns true if we succeeded and false if acquiring a read lock would require blocking.

Source

pub fn write(&self)

Acquire an exclusive write lock.

Blocks until the write lock can be acquired. The lock can be released by calling unlock_write.

Source

pub fn try_write(&self) -> bool

Attempt to acquire an exclusive write lock without blocking.

Returns true if we succeeded and false if acquiring the write lock would require blocking.

Source

pub fn unlock_read(&self)

Unlock a previously acquired read lock.

Behavior is unspecified (but not undefined) if unlock_read is called without a previous accompanying read.

Source

pub fn unlock_write(&self)

Unlock a previously acquired write lock.

Behavior is unspecified (but not undefined) if unlock_write is called without a previous accompanying write.

Source

pub fn wait_from_read_to_write(&self, cond: &Condvar)

Wait on the given condition variable, resuming with a write lock.

Behavior is unspecified if there was no previous accompanying read.

Source

pub fn wait_from_read_to_read(&self, cond: &Condvar)

Wait on the given condition variable, resuming with another read lock.

Behavior is unspecified if there was no previous accompanying read.

Source

pub fn wait_from_write_to_read(&self, cond: &Condvar)

Wait on the given condition variable, resuming with a read lock.

Behavior is unspecified if there was no previous accompanying write.

Source

pub fn wait_from_write_to_write(&self, cond: &Condvar)

Wait on the given condition variable, resuming with another write lock.

Behavior is unspecified if there was no previous accompanying write.

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.