Struct shared_mutex::SharedMutex [] [src]

pub struct SharedMutex<T: ?Sized> { /* fields omitted */ }

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

Similar to std::sync::RwLock, except that its guards (SharedMutexReadGuard and SharedMutexWriteGuard) can wait on std::sync::Condvars, which is very useful for implementing efficient concurrent programs.

Another difference from std::sync::RwLock is that the guard types are Send.

Methods

impl<T> SharedMutex<T>
[src]

Create a new SharedMutex protecting the given value.

Extract the data from the lock and destroy the lock.

Safe since it requires ownership of the lock.

impl<T: ?Sized> SharedMutex<T>
[src]

Acquire an exclusive Write lock on the data.

Acquire a shared Read lock on the data.

Attempt to acquire a shared Read lock on the data.

If acquiring the lock would block, returns TryLockError::WouldBlock.

Attempt to acquire an exclusive Write lock on the data.

If acquiring the lock would block, returns TryLockError::WouldBlock.

Get a mutable reference to the data without locking.

Safe since it requires exclusive access to the lock itself.

Trait Implementations

impl<T: ?Sized + Send> Send for SharedMutex<T>
[src]

impl<T: ?Sized + Sync> Sync for SharedMutex<T>
[src]

impl<T: ?Sized + Debug> Debug for SharedMutex<T>
[src]

Formats the value using the given formatter.