macro_rules! rw_lock {
($expr:expr) => { ... };
($expr:expr, label = $label:literal) => { ... };
($expr:expr, label = $label:expr) => { ... };
}Expand description
Instrument an std::sync::RwLock, parking_lot::RwLock, async_lock::RwLock, or
tokio::sync::RwLock for read/write profiling.
Returns an instrumented drop-in replacement that proxies to the wrapped lock and records
how long read and write locks are held. The wrapper type matches the API of the underlying
lock (std::sync::RwLock returns LockResults; parking_lot::RwLock returns guards directly;
async_lock::RwLock and tokio::sync::RwLock expose async read/write returning guards).
parking_lot::RwLock support requires the parking_lot feature; async_lock::RwLock
support requires the async-lock feature; tokio::sync::RwLock support requires the
tokio feature.
ยงExamples
let lock = hotpath::rw_lock!(std::sync::RwLock::new(0u32));
*lock.write().unwrap() += 1;
let _ = *lock.read().unwrap();