barging
only.Expand description
A barging MCS lock implementation that is compliant with the lock_api crate.
This implementation will have non-waiting threads race for the lock against
the front of the waiting queue thread. If the front of the queue thread
looses the race, it will simply keep spinning, while holding its position
in the queue. By allowing barging instead of forcing FIFO, a higher throughput
can be achieved when the lock is heavily contended. This implementation is
suitable for no_std
environments, and the locking APIs are compatible with
the lock_api crate (see lock_api
feature).
The lock is hold for as long as its associated RAII guard is in scope. Once
the guard is dropped, the mutex is freed. Mutex guards are returned by
lock
and try_lock
. Guards are also accessible as the closure argument
for lock_with
and try_lock_with
methods.
The Mutex is generic over the relax strategy. User may choose a strategy
as long as it implements the Relax
trait. There is a number of strategies
provided by the relax
module. Each submodule provides type aliases for
Mutex
and MutexGuard
associated with one relax strategy. See their
documentation for more information.
Modules§
- A
barging
MCS lock alias that rapidly spins without telling the CPU to do any power down during lock contention. - A
barging
MCS lock alias that signals the processor that it is running a busy-wait spin-loop during lock contention. - yields
yield
Abarging
MCS lock alias that yields the current time slice to the OS scheduler during lock contention.
Structs§
- A mutual exclusion primitive useful for protecting shared data.
- An RAII implementation of a “scoped lock” of a mutex. When this structure is dropped (falls out of scope), the lock will be unlocked.