doc.rust-lang.org
pub const fn new(t: T) -> Mutex<T>
Creates a new mutex in an unlocked state ready for use.
associated_function
std
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn lock(&self) -> LockResult<MutexGuard<'_, T>>
Acquires a mutex, blocking the current thread until it is able to do so.
method
std
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn is_poisoned(&self) -> bool
Determines whether the mutex is poisoned.
method
std
Stable since 1.2.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn into_inner(self) -> LockResult<T>
Consumes this mutex, returning the underlying data.
method
std
Stable since 1.6.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn get_mut(&mut self) -> LockResult<&mut T>
Returns a mutable reference to the underlying data.
method
std
Stable since 1.6.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn clear_poison(&self)
Clear the poisoned state from a mutex.
method
std
Stable since 1.77.0
Version 1.100.0-nightly
doc.rust-lang.org
pub struct Mutex<T>
A mutual exclusion primitive useful for protecting shared data
struct
std
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub struct Condvar
A Condition Variable
struct
std
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub type TryLockResult<Guard> = Result<Guard, TryLockError<Guard>>
A type alias for the result of a nonblocking locking method.
type_alias
std
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub enum TryLockError<T>
An enumeration of possible errors associated with a TryLockResult which can occur while trying to acquire a lock, from the try_lock method on a Mutex or the try_read and try_write methods on an RwLock.
enum
std
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub struct PoisonError<T>
A type of error which can be returned whenever a lock is acquired.
struct
std
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub type LockResult<T> = Result<T, PoisonError<T>>
A type alias for the result of a lock method which can be poisoned.
type_alias
std
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn wait(&self) -> &T
Blocks the current thread until the cell is initialized.
method
std
Stable since 1.86.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn take(&mut self) -> Option<T>
Takes the value out of this OnceLock, moving it back to an uninitialized state.
method
std
Stable since 1.70.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn set(&self, value: T) -> Result<(), T>
Initializes the contents of the cell to value.
method
std
Stable since 1.70.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const fn new() -> OnceLock<T>
Creates a new uninitialized cell.
associated_function
std
Stable since 1.70.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn into_inner(self) -> Option<T>
Consumes the OnceLock, returning the wrapped value. Returns None if the cell was uninitialized.
method
std
Stable since 1.70.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn get_or_init<F>(&self, f: F) -> &T
Gets the contents of the cell, initializing it to f() if the cell was uninitialized.
method
std
Stable since 1.70.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn get_mut(&mut self) -> Option<&mut T>
Gets the mutable reference to the underlying value.
method
std
Stable since 1.70.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn get(&self) -> Option<&T>
Gets the reference to the underlying value.
method
std
Stable since 1.70.0
Version 1.100.0-nightly