pub struct Mutex<T: ?Sized> { /* private fields */ }
Expand description

Exposes the kernel’s struct mutex. When multiple threads attempt to lock the same mutex, only one at a time is allowed to progress, the others will block (sleep) until the mutex is unlocked, at which point another thread will be allowed to wake up and make progress.

A Mutex must first be initialised with a call to Mutex::init_lock before it can be used. The mutex_init macro is provided to automatically assign a new lock class to a mutex instance.

Since it may block, Mutex needs to be used with care in atomic contexts.

Implementations

Constructs a new mutex.

Safety

The caller must call Mutex::init_lock before using the mutex.

Locks the mutex and gives the caller access to the data protected by it. Only one thread at a time is allowed to access the protected data.

Trait Implementations

The type of the data protected by the lock.

The type of context, if any, that needs to be stored in the guard.

Acquires the lock, making the caller its owner.

Releases the lock, giving up ownership of the lock. Read more

Returns the data protected by the lock.

Reacquires the lock, making the caller its owner. Read more

The parametrised type of the mutual exclusion primitive that can be created by this factory.

Constructs a new instance of the mutual exclusion primitive. Read more

Initialises the lock instance so that it can be safely used.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Initialises the type instance so that it can be safely used. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

This documentation is an old archive. Please see https://rust.docs.kernel.org instead.