Crate usync

Source
Expand description

This library provides implementations of Mutex, RwLock, Condvar, Barrier, and Once that are smaller and faster than those in the Rust standard library. It also provides a ReentrantMutex type.

Everything is powered by lock-free thread queues in userspace which allows the synchronization primitives to be 1 word (usize) large. All thread blocking is done through std::thread::park for maximum portability.

Re-exports§

pub use ::lock_api;

Structs§

Barrier
A barrier enables multiple threads to synchronize the beginning of some computation.
BarrierWaitResult
A BarrierWaitResult is returned by Barrier::wait() when all threads in the Barrier have rendezvoused.
Condvar
A Condition Variable
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.
RawMutex
Raw mutex type implemented with lock-free userspace thread queues.
RawRwLock
Raw rwlock type implemented with lock-free userspace thread queues.
RawThreadId
Implementation of the GetThreadId trait for lock_api::ReentrantMutex.
WaitTimeoutResult
A type indicating whether a timed wait on a condition variable returned due to a time out or not.

Enums§

OnceState
Current state of a Once.

Functions§

const_mutex
Creates a new mutex in an unlocked state ready for use.
const_reentrant_mutex
Creates a new reentrant mutex in an unlocked state ready for use.
const_rwlock
Creates a new instance of an RwLock<T> which is unlocked.

Type Aliases§

MappedMutexGuard
An RAII mutex guard returned by MutexGuard::map, which can point to a subfield of the protected data.
MappedReentrantMutexGuard
An RAII mutex guard returned by ReentrantMutexGuard::map, which can point to a subfield of the protected data.
MappedRwLockReadGuard
An RAII read lock guard returned by RwLockReadGuard::map, which can point to a subfield of the protected data.
MappedRwLockWriteGuard
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
MutexGuard
An RAII implementation of a “scoped lock” of a mutex. When this structure is dropped (falls out of scope), the lock will be unlocked.
ReentrantMutex
A mutex which can be recursively locked by a single thread.
ReentrantMutexGuard
An RAII implementation of a “scoped lock” of a reentrant mutex. When this structure is dropped (falls out of scope), the lock will be unlocked.
RwLock
A reader-writer lock
RwLockReadGuard
RAII structure used to release the shared read access of a lock when dropped.
RwLockWriteGuard
RAII structure used to release the exclusive write access of a lock when dropped.