Module lilos::mutex [−][src]
Fair mutex that must be pinned.
This implements a mutex, or lock, guarding a value of type T
. Creating a
Mutex
by hand is somewhat involved (see Mutex::new
for details), so
there’s a convenience macro, create_mutex!
.
If you don’t want to store a value inside the mutex, use a Mutex<()>
.
Implementation details
This implementation uses a wait-list to track all processes that are waiting to unlock the mutex. This makes unlocking more expensive, but means that the unlock operation is fair, preventing starvation of contending tasks.
However, in exchange for this property, mutexes must be pinned, which makes using them slightly more awkward.
Structs
Mutex | Holds a |
MutexGuard | Smart pointer representing successful locking of a mutex. |