pub struct Mutex<T> { /* private fields */ }Expand description
The basic mutex type. Mutexes are used to share variables between tasks safely.
Implementations§
Source§impl<T> Mutex<T>
impl<T> Mutex<T>
Sourcepub fn lock(&self) -> MutexGuard<'_, T>
pub fn lock(&self) -> MutexGuard<'_, T>
Locks the mutex so that it cannot be locked in another task at the same time. Blocks the current task until the lock is acquired.
Sourcepub fn try_lock(&self) -> Option<MutexGuard<'_, T>>
pub fn try_lock(&self) -> Option<MutexGuard<'_, T>>
Attempts to acquire this lock. This function does not block.
Sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Consumes the mutex and returns the inner data.
Trait Implementations§
impl<T: Send> Send for Mutex<T>
impl<T> Sync for Mutex<T>
Auto Trait Implementations§
impl<T> !Freeze for Mutex<T>
impl<T> !RefUnwindSafe for Mutex<T>
impl<T> Unpin for Mutex<T>where
T: Unpin,
impl<T> UnsafeUnpin for Mutex<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for Mutex<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more