mirror of
https://github.com/bertptrs/tracing-mutex.git
synced 2025-12-25 20:50:32 +01:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 536ee31138 | |||
| e2db0eaca8 | |||
| 158e5353bb |
16
CHANGELOG.md
16
CHANGELOG.md
@@ -6,18 +6,30 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [0.1.2] - 2021-05-27
|
||||
|
||||
### Added
|
||||
- Added missing type aliases for the guards returned by `DebugMutex` and `DebugRwLock`. These new
|
||||
type aliases function the same as the ones they belong to, resolving to either the tracing
|
||||
versions when debug assertions are enabled or the standard one when they're not.
|
||||
|
||||
### Fixed
|
||||
- Fixed a corruption error where deallocating a previously cyclic mutex could result in a panic.
|
||||
|
||||
## [0.1.1] - 2021-05-24
|
||||
|
||||
### Changed
|
||||
- New data structure for interal dependency graph, resulting in quicker graph updates.
|
||||
|
||||
### Fixed
|
||||
- Fixed an issue where internal graph ordering indices were exponential rather than sequential.
|
||||
- Fixed an issue where internal graph ordering indices were exponential rather than sequential. This
|
||||
caused the available IDs to run out way more quickly than intended.
|
||||
|
||||
## [0.1.0] - 2021-05-16 [YANKED]
|
||||
|
||||
Initial release.
|
||||
|
||||
[Unreleased]: https://github.com/bertptrs/tracing-mutex/compare/v0.1.1...HEAD
|
||||
[Unreleased]: https://github.com/bertptrs/tracing-mutex/compare/v0.1.2...HEAD
|
||||
[0.1.2]: https://github.com/bertptrs/tracing-mutex/compare/v0.1.2...v0.1.2
|
||||
[0.1.1]: https://github.com/bertptrs/tracing-mutex/compare/v0.1.0...v0.1.1
|
||||
[0.1.0]: https://github.com/bertptrs/tracing-mutex/releases/tag/v0.1.0
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "tracing-mutex"
|
||||
version = "0.1.1"
|
||||
version = "0.1.2"
|
||||
authors = ["Bert Peters <bert@bertptrs.nl>"]
|
||||
edition = "2018"
|
||||
license = "MIT OR Apache-2.0"
|
||||
|
||||
@@ -127,7 +127,7 @@ where
|
||||
// We use map instead of unwrap to avoid an `unwrap()` but we know that these
|
||||
// entries are present as we just added them above.
|
||||
self.nodes.get_mut(&y).map(|node| node.in_edges.remove(&x));
|
||||
self.nodes.get_mut(&x).map(|node| node.out_edges.remove(&x));
|
||||
self.nodes.get_mut(&x).map(|node| node.out_edges.remove(&y));
|
||||
|
||||
// No edge was added
|
||||
return false;
|
||||
|
||||
12
src/lib.rs
12
src/lib.rs
@@ -304,6 +304,18 @@ mod tests {
|
||||
assert!(get_dependency_graph().add_edge(c.value(), a.value()));
|
||||
}
|
||||
|
||||
/// Test creating a cycle, then panicking.
|
||||
#[test]
|
||||
#[should_panic]
|
||||
fn test_mutex_id_conflict() {
|
||||
let ids = [MutexId::new(), MutexId::new(), MutexId::new()];
|
||||
|
||||
for i in 0..3 {
|
||||
let _first_lock = ids[i].get_borrowed();
|
||||
let _second_lock = ids[(i + 1) % 3].get_borrowed();
|
||||
}
|
||||
}
|
||||
|
||||
/// Fuzz the global dependency graph by fake-acquiring lots of mutexes in a valid order.
|
||||
///
|
||||
/// This test generates all possible forward edges in a 100-node graph consisting of natural
|
||||
|
||||
@@ -42,6 +42,12 @@ pub type DebugMutex<T> = TracingMutex<T>;
|
||||
#[cfg(not(debug_assertions))]
|
||||
pub type DebugMutex<T> = Mutex<T>;
|
||||
|
||||
/// Mutex guard for [`DebugMutex`].
|
||||
#[cfg(debug_assertions)]
|
||||
pub type DebugMutexGuard<'a, T> = TracingMutexGuard<'a, T>;
|
||||
#[cfg(not(debug_assertions))]
|
||||
pub type DebugMutexGuard<'a, T> = MutexGuard<'a, T>;
|
||||
|
||||
/// Debug-only tracing `RwLock`.
|
||||
///
|
||||
/// Type alias that resolves to [`TracingRwLock`] when debug assertions are enabled and to
|
||||
@@ -52,6 +58,18 @@ pub type DebugRwLock<T> = TracingRwLock<T>;
|
||||
#[cfg(not(debug_assertions))]
|
||||
pub type DebugRwLock<T> = RwLock<T>;
|
||||
|
||||
/// Read guard for [`DebugRwLock`].
|
||||
#[cfg(debug_assertions)]
|
||||
pub type DebugReadGuard<'a, T> = TracingReadGuard<'a, T>;
|
||||
#[cfg(not(debug_assertions))]
|
||||
pub type DebugReadGuard<'a, T> = RwLockReadGuard<'a, T>;
|
||||
|
||||
/// Write guard for [`DebugRwLock`].
|
||||
#[cfg(debug_assertions)]
|
||||
pub type DebugWriteGuard<'a, T> = TracingWriteGuard<'a, T>;
|
||||
#[cfg(not(debug_assertions))]
|
||||
pub type DebugWriteGuard<'a, T> = RwLockWriteGuard<'a, T>;
|
||||
|
||||
/// Debug-only tracing `Once`.
|
||||
///
|
||||
/// Type alias that resolves to [`TracingOnce`] when debug assertions are enabled and to
|
||||
|
||||
Reference in New Issue
Block a user