Module lock_api

Module lock_api 

Source
Available on crate features barging and lock_api only.
Expand description

Unfair MCS lock aliases for lock_api::Mutex.

This module exports lock_api::Mutex and lock_api::MutexGuard type aliases with a barging MCS lock and guard as their inner types. The barging::Mutex type will implement the lock_api::RawMutex trait when this feature is enabled. The barging MCS lock is a unfair lock.

This module provides an implementation that is no_std compatible.

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.

This Mutex is generic over the two layers of relax policies. User may choose a policy as long as it implements the Relax trait. The shared lock relax policy is associated with the Rs generic paramater. The handoff relax policy is then associated with the Rq generic parameter. Backoff relax policies are usually prefered for shared lock contention, while non-backoff relax policies are usually prefered for handoffs.

There is a number of relax policies provided by the relax module. The following modules provide type aliases for lock_api::Mutex and lock_api::MutexGuard associated with a relax policy. See their documentation for more information.

Modules§

loops
An unfair MCS lock that implements a loop relax policy.
spins
An unfair MCS lock that implements a spin relax policy.
yieldsyield
An unfair MCS lock that implements a yield relax policy.

Type Aliases§

Mutex
A lock_api::Mutex alias that wraps a barging::Mutex.
MutexGuard
A lock_api::MutexGuard alias that wraps a barging::MutexGuard.