RawMutex
, RawRwLock
and RawThreadId
.lock_api/nightly
feature from parking_lot/nightly
(#79)Added missing typedefs for mapped lock guards:
MappedMutexGuard
MappedReentrantMutexGuard
MappedRwLockReadGuard
MappedRwLockWriteGuard
This release moves most of the code for type-safe Mutex
and RwLock
types into a separate crate called lock_api
. This new crate is compatible with no_std
and provides Mutex
and RwLock
type-safe wrapper types from a raw mutex type which implements the RawMutex
or RawRwLock
trait. The API provided by the wrapper types can be extended by implementing more traits on the raw mutex type which provide more functionality (e.g. RawMutexTimed
). See the crate documentation for more details.
There are also several major changes:
MutexGuard
(and other guard types) are no longer inherent methods and must be called as MutexGuard::method(self)
. This avoids conflicts with methods from the inner type.MutexGuard
(and other guard types) add the unlocked
method which temporarily unlocks a mutex, runs the given closure, and then re-locks the mutex.MutexGuard
(and other guard types) add the bump
method which gives a chance for other threads to acquire the mutex by temporarily unlocking it and re-locking it. However this is optimized for the common case where there are no threads waiting on the lock, in which case no unlocking is performed.MutexGuard
(and other guard types) add the map
method which returns a MappedMutexGuard
which holds only a subset of the original locked type. The MappedMutexGuard
type is identical to MutexGuard
except that it does not support the unlocked
and bump
methods, and can't be used with CondVar
.