[][src]Struct sync_panic::Mutex

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

A mutual exclusion primitive useful for protecting shared data.

Methods

impl<T> Mutex<T>[src]

pub fn new(value: T) -> Mutex<T>[src]

Creates a new mutex in an unlocked state ready for use.

pub fn into_inner(self) -> T[src]

Consumes this mutex, returning the underlying data.

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

pub fn lock(&self) -> MutexGuard<T>[src]

Acquires a mutex, blocking the current thread until it is able to do so.

This function will block the local thread until it is available to acquire the mutex. Upon returning, the thread is the only thread with the lock held. An RAII guard is returned to allow scoped unlock of the lock. When the guard goes out of scope, the mutex will be unlocked.

pub fn try_lock(&self) -> Result<MutexGuard<T>, WouldBlock>[src]

Attempts to acquire this lock.

If the lock could not be acquired at this time, then Err is returned. Otherwise, an RAII guard is returned. The lock will be unlocked when the guard is dropped.

This function does not block.

pub fn get_mut(&mut self) -> &mut T[src]

Returns a mutable reference to the underlying data.

Since this call borrows the Mutex mutably, no actual locking needs to take place -- the mutable borrow statically guarantees no locks exist.

Trait Implementations

impl<T> From<T> for Mutex<T>[src]

impl<T: Default + ?Sized> Default for Mutex<T>[src]

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

Auto Trait Implementations

impl<T: ?Sized> Send for Mutex<T> where
    T: Send

impl<T: ?Sized> Sync for Mutex<T> where
    T: Send

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.