[−][src]Struct greenie::common::mutex::Mutex
A mutual exclusion primitive useful for protecting shared data
This mutex will block threads waiting for the lock to become available. The mutex can also be statically initialized or created via a new constructor. Each mutex has a type parameter which represents the data that it is protecting. The data can only be accessed through the RAII guards returned from lock and try_lock, which guarantees that the data is only ever accessed when the mutex is locked.
Methods
impl Mutex
[src]
pub fn new() -> Self
[src]
Creates a new mutex in an unlocked state ready for use.
pub fn lock(&self)
[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.
The exact behavior on locking a mutex in the thread which already holds the lock is left unspecified. However, this function will not return on the second call (it might panic or deadlock, for example).
pub fn try_lock(&self) -> bool
[src]
Attempts to acquire this lock.
If the lock could not be acquired at this time, then false
is returned. Otherwise, true
is returned.
This function does not block.
pub fn unlock(&self)
[src]
Trait Implementations
impl Clone for Mutex
[src]
impl Drop for Mutex
[src]
impl Eq for Mutex
[src]
impl PartialEq<Mutex> for Mutex
[src]
impl StructuralEq for Mutex
[src]
impl StructuralPartialEq for Mutex
[src]
Auto Trait Implementations
impl !RefUnwindSafe for Mutex
impl !Send for Mutex
impl !Sync for Mutex
impl Unpin for Mutex
impl !UnwindSafe for Mutex
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,