Expand description
Helpers for tracing and troubleshooting multithreaded code.
§Usage
Import RwLock and Mutex from this crate instead of parking_lot directly.
After this, you can instrument a section of code like this:
let condition = true;
if condition {
unlock::capture(true);
}
/* do some work */
if condition {
unlock::capture(false);
let events = unlock::drain();
let f = std::fs::File::create("trace.html")?;
unlock::html::write(f, &events)?;
println!("Wrote trace.html");
}§How does it work
This library provides two facade types:
These integrate with a high performance concurrent tracing system to capture events. While this will have some overhead, we aim to make it as small as possible.
Once a workload has been instrumented, the drain function can be called to
collect these events, which then can be formatted using either built-in
methods such as html::write, or serialized as you please using serde
for processing later.
Modules§
- Module to format captured lock events as html.
Structs§
- A recorded event.
Functions§
- Indicate whether capture is enabled or not.
- Drain the current capture of events.
Type Aliases§
- A mutual exclusion primitive useful for protecting shared data
- An RAII implementation of a “scoped lock” of a mutex. When this structure is dropped (falls out of scope), the lock will be unlocked.
- A reader-writer lock
- RAII structure used to release the shared read access of a lock when dropped.
- RAII structure used to release the exclusive write access of a lock when dropped.