parkinglot feature has been renamed parking_lotExpand description
Wrapper types and type aliases for tracing parking_lot mutexes.
This module provides type aliases that use the lockapi module to provide
tracing variants of the parking_lot primitives. The tracing module contains type aliases
that use dependency tracking, while the main parking_lot primitives are reexported as raw.
This main module imports from tracing when debug_assertions are enabled, and from raw
when they’re not. Note that primitives for which no tracing wrapper exists are not imported into
the main module.
§Usage
use tracing_mutex::parkinglot::Mutex;
let mutex = Arc::new(Mutex::new(0));
let handles: Vec<_> = (0..10).map(|_| {
let mutex = Arc::clone(&mutex);
thread::spawn(move || *mutex.lock() += 1)
}).collect();
handles.into_iter().for_each(|handle| handle.join().unwrap());
// All threads completed so the value should be 10.
assert_eq!(10, *mutex.lock());§Limitations
The main lock for the global state is still provided by std::sync and the tracing primitives
are larger than the parking_lot primitives they wrap, so there can be a performance
degradation between using this and using parking_lot directly. If this is of concern to you,
try using the DebugX-structs, which provide cycle detection only when debug_assertions are
enabled and have no overhead when they’re not.
In addition, the mutex guards returned by the tracing wrappers are !Send, regardless of
whether parking_lot is configured to have Send mutex guards. This is a limitation of the
current bookkeeping system.
Re-exports§
pub use tracing::FairMutex;Deprecated pub use tracing::FairMutexGuard;Deprecated pub use tracing::MappedFairMutexGuard;Deprecated pub use tracing::MappedMutexGuard;Deprecated pub use tracing::MappedReentrantMutexGuard;Deprecated pub use tracing::MappedRwLockReadGuard;Deprecated pub use tracing::MappedRwLockWriteGuard;Deprecated pub use tracing::Mutex;Deprecated pub use tracing::MutexGuard;Deprecated pub use tracing::Once;Deprecated pub use tracing::RawFairMutex;Deprecated pub use tracing::RawMutex;Deprecated pub use tracing::RawRwLock;Deprecated pub use tracing::ReentrantMutex;Deprecated pub use tracing::ReentrantMutexGuard;Deprecated pub use tracing::RwLock;Deprecated pub use tracing::RwLockReadGuard;Deprecated pub use tracing::RwLockUpgradableReadGuard;Deprecated pub use tracing::RwLockWriteGuard;Deprecated pub use tracing::const_fair_mutex;Deprecated pub use tracing::const_mutex;Deprecated pub use tracing::const_reentrant_mutex;Deprecated pub use tracing::const_rwlock;Deprecated pub use parking_lot as raw;
Modules§
- tracing
Deprecated - Dependency tracing wrappers for
::parking_lot.
Structs§
- RawThread
Id - Implementation of the
GetThreadIdtrait forlock_api::ReentrantMutex. - Wait
Timeout Result - A type indicating whether a timed wait on a condition variable returned due to a time out or not.
Enums§
- Once
State - Current state of a
Once.