Struct shared_mutex::SharedMutex [] [src]

pub struct SharedMutex<T: ?Sized> {
    // some 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]

fn new(value: T) -> Self

Create a new SharedMutex protecting the given value.

fn into_inner(self) -> T

Extract the data from the lock and destroy the lock.

Safe since it requires ownership of the lock.

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

fn write(&self) -> SharedMutexWriteGuard<T>

Acquire an exclusive Write lock on the data.

fn read(&self) -> SharedMutexReadGuard<T>

Acquire a shared Read lock on the data.

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

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]