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