Expand description
This library provides compact and efficient implementations of Mutex,
FairMutex, ReentrantMutex, RwLock, RecursiveRwLock,
Condvar and Once.
§Use in global allocators
The synchronization primitives in this crate must not be used internally by a global allocator. Their contended paths may allocate memory, including while internal parking-lot locks are held. If the allocator then blocks on one of these primitives, it may recursively invoke itself or deadlock.
Re-exports§
pub use ::lock_api;
Modules§
- deadlock
- [Experimental] Deadlock detection
Structs§
- ArcMutex
Guard - An RAII mutex guard returned by the
Arclocking operations onMutex. - ArcReentrant
Mutex Guard - An RAII mutex guard returned by the
Arclocking operations onReentrantMutex. - ArcRw
Lock Read Guard - An RAII read guard returned by the
Arclocking operations onRwLock. - ArcRw
Lock Upgradable Read Guard - An RAII upgradable read guard returned by the
Arclocking operations onRwLock. UnlikeRwLockUpgradableReadGuard, this guard owns theArcused to unlock the reader-writer lock instead of borrowing it, so its lifetime is not tied to a lock reference. - ArcRw
Lock Write Guard - An RAII write guard returned by the
Arclocking operations onRwLock. UnlikeRwLockWriteGuard, this guard owns theArcused to unlock the reader-writer lock instead of borrowing it, so its lifetime is not tied to a lock reference. - Once
- A synchronization primitive which can be used to run a one-time initialization. Useful for one-time initialization for globals, FFI or related functionality.
- RawCondvar
- A raw condition variable.
- RawFair
Mutex - Raw fair mutex type backed by the parking lot.
- RawMutex
- Raw mutex type backed by the parking lot.
- RawRw
Lock - Raw reader-writer lock type backed by the parking lot.
- RawThread
Id - Implementation of the
GetThreadIdtrait forlock_api::ReentrantMutex. - Wait
Timeout Result - A type indicating whether a timed wait on a condition variable timed out.
Enums§
- Once
State - Current state of a
Once.
Type Aliases§
- Condvar
- A condition variable.
- Fair
Mutex - A mutual exclusion primitive that uses fair unlocking, useful for protecting shared data.
- Fair
Mutex Guard - An RAII guard which unlocks the mutex when dropped.
- Mapped
Fair Mutex Guard - An RAII mutex guard returned by
FairMutexGuard::map, which can point to a subfield of the protected data. - Mapped
Mutex Guard - An RAII mutex guard returned by
MutexGuard::map, which can point to a subfield of the protected data. - Mapped
Recursive RwLock Read Guard - A mapped RAII guard which releases shared access when dropped.
- Mapped
Recursive RwLock Write Guard - A mapped RAII guard which releases exclusive access when dropped.
- Mapped
Reentrant Mutex Guard - An RAII mutex guard returned by
ReentrantMutexGuard::map, which can point to a subfield of the protected data. - Mapped
RwLock Read Guard - An RAII read lock guard returned by
RwLockReadGuard::map, which can point to a subfield of the protected data. - Mapped
RwLock Write Guard - An RAII write lock guard returned by
RwLockWriteGuard::map, which can point to a subfield of the protected data. - Mutex
- A mutual exclusion primitive useful for protecting shared data.
- Mutex
Guard - An RAII guard which unlocks the mutex when dropped.
- RawRw
Lock Recursive - Raw reader-writer lock which permits recursive read locking.
- Recursive
RwLock - A reader-writer lock which permits recursive read locking.
- Recursive
RwLock Read Guard - An RAII guard which releases shared read access when dropped.
- Recursive
RwLock Upgradable Read Guard - An RAII guard which releases upgradable read access when dropped.
- Recursive
RwLock Write Guard - An RAII guard which releases exclusive write access when dropped.
- Reentrant
Mutex - A reentrant mutual exclusion lock.
- Reentrant
Mutex Guard - An RAII guard which releases one level of recursive locking when dropped.
- RwLock
- A reader-writer lock.
- RwLock
Read Guard - An RAII guard which releases shared read access when dropped.
- RwLock
Upgradable Read Guard - An RAII guard which releases upgradable read access when dropped.
- RwLock
Write Guard - An RAII guard which releases exclusive write access when dropped.