Struct shared_mutex::RawSharedMutex
[−]
[src]
pub struct RawSharedMutex { /* fields omitted */ }
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.
Methods
impl RawSharedMutex
[src]
fn new() -> RawSharedMutex
Create a new RawSharedMutex
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.
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
.
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.
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
.
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.
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
.
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
.
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
.
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
.
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
.
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
.