3 Commits

Author SHA1 Message Date
536ee31138 Prepare for relesae 2021-05-27 21:13:24 +02:00
e2db0eaca8 Fix a graph invariant violation on cycle detection 2021-05-27 20:31:00 +02:00
158e5353bb Add missing guard type aliases 2021-05-24 20:28:49 +02:00
5 changed files with 46 additions and 4 deletions

View File

@@ -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

View File

@@ -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"

View File

@@ -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;

View File

@@ -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

View File

@@ -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