Struct kernel::sync::Mutex[][src]

pub struct Mutex<T: ?Sized> { /* fields omitted */ }
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 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 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.

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.

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

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

Performs the conversion.

Performs the conversion.

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.