mirror of
https://github.com/bertptrs/tracing-mutex.git
synced 2025-12-28 05:50:32 +01:00
Compare commits
8 Commits
9a79b53147
...
v0.3.1
| Author | SHA1 | Date | |
|---|---|---|---|
| 522ee3ffe5 | |||
| 1791ef5243 | |||
| 4b872c1262 | |||
| 99bca9852c | |||
| b396016224 | |||
| c29ccc4f4d | |||
| 8ec32bdf16 | |||
| ccc4c98791 |
6
.github/workflows/ci.yml
vendored
6
.github/workflows/ci.yml
vendored
@@ -30,9 +30,13 @@ jobs:
|
|||||||
|
|
||||||
# Make sure we test with recent deps
|
# Make sure we test with recent deps
|
||||||
- run: cargo update
|
- run: cargo update
|
||||||
|
# Note: some crates broke BC with 1.74 so we use the locked deps
|
||||||
|
if: "${{ matrix.rust != '1.74' }}"
|
||||||
- run: cargo build --all-features --all-targets
|
- run: cargo build --all-features --all-targets
|
||||||
- run: cargo test --all-features
|
- run: cargo test --all-features
|
||||||
- run: cargo fmt --all -- --check
|
- run: cargo fmt --all -- --check
|
||||||
|
# Note: Rust 1.74 doesn't understand edition 2024 formatting so no point
|
||||||
|
if: "${{ matrix.rust != '1.74' }}"
|
||||||
- run: cargo clippy --all-features --all-targets -- -D warnings
|
- run: cargo clippy --all-features --all-targets -- -D warnings
|
||||||
|
|
||||||
msrv:
|
msrv:
|
||||||
@@ -46,7 +50,7 @@ jobs:
|
|||||||
toolchain: "1.70"
|
toolchain: "1.70"
|
||||||
|
|
||||||
# Test everything except experimental features.
|
# Test everything except experimental features.
|
||||||
- run: cargo test --features backtraces,lockapi,parkinglot
|
- run: cargo test --features backtraces,lock_api,parking_lot
|
||||||
|
|
||||||
docs:
|
docs:
|
||||||
name: Documentation build
|
name: Documentation build
|
||||||
|
|||||||
13
CHANGELOG.md
13
CHANGELOG.md
@@ -27,6 +27,16 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|||||||
|
|
||||||
- Reworked CI to better test continued support for the minimum supported Rust version
|
- Reworked CI to better test continued support for the minimum supported Rust version
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Support for `parking_lot` and `lock_api` can now be enabled properly with the matching feature
|
||||||
|
names.
|
||||||
|
|
||||||
|
### Deprecated
|
||||||
|
|
||||||
|
- The `parkinglot` and `lockapi` features have been deprecated. They will be removed in version 0.4.
|
||||||
|
To fix it, you can use the `parking_lot` and `lock_api` features respectively.
|
||||||
|
|
||||||
## [0.3.0] - 2023-09-09
|
## [0.3.0] - 2023-09-09
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
@@ -114,7 +124,8 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|||||||
|
|
||||||
Initial release.
|
Initial release.
|
||||||
|
|
||||||
[Unreleased]: https://github.com/bertptrs/tracing-mutex/compare/v0.3.0...HEAD
|
[Unreleased]: https://github.com/bertptrs/tracing-mutex/compare/v0.3.1...HEAD
|
||||||
|
[0.3.1]: https://github.com/bertptrs/tracing-mutex/compare/v0.3.0...v0.3.1
|
||||||
[0.3.0]: https://github.com/bertptrs/tracing-mutex/compare/v0.2.1...v0.3.0
|
[0.3.0]: https://github.com/bertptrs/tracing-mutex/compare/v0.2.1...v0.3.0
|
||||||
[0.2.1]: https://github.com/bertptrs/tracing-mutex/compare/v0.2.0...v0.2.1
|
[0.2.1]: https://github.com/bertptrs/tracing-mutex/compare/v0.2.0...v0.2.1
|
||||||
[0.2.0]: https://github.com/bertptrs/tracing-mutex/compare/v0.1.2...v0.2.0
|
[0.2.0]: https://github.com/bertptrs/tracing-mutex/compare/v0.1.2...v0.2.0
|
||||||
|
|||||||
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -597,7 +597,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tracing-mutex"
|
name = "tracing-mutex"
|
||||||
version = "0.3.0"
|
version = "0.3.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"autocfg",
|
"autocfg",
|
||||||
"criterion",
|
"criterion",
|
||||||
|
|||||||
13
Cargo.toml
13
Cargo.toml
@@ -1,10 +1,8 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "tracing-mutex"
|
name = "tracing-mutex"
|
||||||
version = "0.3.0"
|
version = "0.3.1"
|
||||||
authors = ["Bert Peters <bert@bertptrs.nl>"]
|
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
documentation = "https://docs.rs/tracing-mutex"
|
|
||||||
categories = ["concurrency", "development-tools::debugging"]
|
categories = ["concurrency", "development-tools::debugging"]
|
||||||
keywords = ["mutex", "rwlock", "once", "thread"]
|
keywords = ["mutex", "rwlock", "once", "thread"]
|
||||||
description = "Ensure deadlock-free mutexes by allocating in order, or else."
|
description = "Ensure deadlock-free mutexes by allocating in order, or else."
|
||||||
@@ -38,9 +36,12 @@ required-features = ["parkinglot"]
|
|||||||
default = ["backtraces"]
|
default = ["backtraces"]
|
||||||
backtraces = []
|
backtraces = []
|
||||||
experimental = []
|
experimental = []
|
||||||
# Feature names do not match crate names pending namespaced features.
|
lock_api = ["dep:lock_api"]
|
||||||
lockapi = ["lock_api"]
|
parking_lot = ["dep:parking_lot", "lock_api"]
|
||||||
parkinglot = ["parking_lot", "lockapi"]
|
|
||||||
|
# Deprecated feature names from when cargo couldn't distinguish between dep and feature
|
||||||
|
lockapi = ["dep:lock_api"]
|
||||||
|
parkinglot = ["dep:parking_lot", "lock_api"]
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
autocfg = "1.4.0"
|
autocfg = "1.4.0"
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::sync::Mutex;
|
use std::sync::Mutex;
|
||||||
|
|
||||||
use criterion::criterion_group;
|
|
||||||
use criterion::criterion_main;
|
|
||||||
use criterion::BenchmarkId;
|
use criterion::BenchmarkId;
|
||||||
use criterion::Criterion;
|
use criterion::Criterion;
|
||||||
use criterion::Throughput;
|
use criterion::Throughput;
|
||||||
|
use criterion::criterion_group;
|
||||||
|
use criterion::criterion_main;
|
||||||
use rand::prelude::*;
|
use rand::prelude::*;
|
||||||
use tracing_mutex::stdsync::tracing::Mutex as TracingMutex;
|
use tracing_mutex::stdsync::tracing::Mutex as TracingMutex;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
status = [
|
|
||||||
'Rust project (1.70)',
|
|
||||||
'Rust project (stable)',
|
|
||||||
'Rust project (beta)',
|
|
||||||
'Documentation build',
|
|
||||||
]
|
|
||||||
1
rustfmt.toml
Normal file
1
rustfmt.toml
Normal file
@@ -0,0 +1 @@
|
|||||||
|
style_edition="2024"
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
use std::collections::hash_map::Entry;
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
|
use std::collections::hash_map::Entry;
|
||||||
use std::hash::Hash;
|
use std::hash::Hash;
|
||||||
|
|
||||||
type Order = usize;
|
type Order = usize;
|
||||||
|
|||||||
36
src/lib.rs
36
src/lib.rs
@@ -77,30 +77,40 @@ use std::fmt;
|
|||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
use std::ops::DerefMut;
|
use std::ops::DerefMut;
|
||||||
use std::sync::atomic::AtomicUsize;
|
|
||||||
use std::sync::atomic::Ordering;
|
|
||||||
use std::sync::Mutex;
|
use std::sync::Mutex;
|
||||||
use std::sync::MutexGuard;
|
use std::sync::MutexGuard;
|
||||||
use std::sync::OnceLock;
|
use std::sync::OnceLock;
|
||||||
use std::sync::PoisonError;
|
use std::sync::PoisonError;
|
||||||
|
use std::sync::atomic::AtomicUsize;
|
||||||
|
use std::sync::atomic::Ordering;
|
||||||
|
|
||||||
#[cfg(feature = "lockapi")]
|
#[cfg(feature = "lock_api")]
|
||||||
#[cfg_attr(docsrs, doc(cfg(feature = "lockapi")))]
|
#[cfg_attr(docsrs, doc(cfg(feature = "lockapi")))]
|
||||||
|
#[deprecated = "The top-level re-export `lock_api` is deprecated. Use `tracing_mutex::lockapi::raw` instead"]
|
||||||
pub use lock_api;
|
pub use lock_api;
|
||||||
#[cfg(feature = "parkinglot")]
|
#[cfg(feature = "parking_lot")]
|
||||||
#[cfg_attr(docsrs, doc(cfg(feature = "parkinglot")))]
|
#[cfg_attr(docsrs, doc(cfg(feature = "parkinglot")))]
|
||||||
|
#[deprecated = "The top-level re-export `parking_lot` is deprecated. Use `tracing_mutex::parkinglot::raw` instead"]
|
||||||
pub use parking_lot;
|
pub use parking_lot;
|
||||||
|
|
||||||
|
use graph::DiGraph;
|
||||||
use reporting::Dep;
|
use reporting::Dep;
|
||||||
use reporting::Reportable;
|
use reporting::Reportable;
|
||||||
|
|
||||||
use crate::graph::DiGraph;
|
|
||||||
|
|
||||||
mod graph;
|
mod graph;
|
||||||
#[cfg(feature = "lockapi")]
|
#[cfg(any(feature = "lock_api", feature = "lockapi"))]
|
||||||
#[cfg_attr(docsrs, doc(cfg(feature = "lockapi")))]
|
#[cfg_attr(docsrs, doc(cfg(feature = "lock_api")))]
|
||||||
|
#[cfg_attr(
|
||||||
|
all(not(docsrs), feature = "lockapi", not(feature = "lock_api")),
|
||||||
|
deprecated = "The `lockapi` feature has been renamed `lock_api`"
|
||||||
|
)]
|
||||||
pub mod lockapi;
|
pub mod lockapi;
|
||||||
#[cfg(feature = "parkinglot")]
|
#[cfg(any(feature = "parking_lot", feature = "parkinglot"))]
|
||||||
#[cfg_attr(docsrs, doc(cfg(feature = "parkinglot")))]
|
#[cfg_attr(docsrs, doc(cfg(feature = "parking_lot")))]
|
||||||
|
#[cfg_attr(
|
||||||
|
all(not(docsrs), feature = "parkinglot", not(feature = "parking_lot")),
|
||||||
|
deprecated = "The `parkinglot` feature has been renamed `parking_lot`"
|
||||||
|
)]
|
||||||
pub mod parkinglot;
|
pub mod parkinglot;
|
||||||
mod reporting;
|
mod reporting;
|
||||||
pub mod stdsync;
|
pub mod stdsync;
|
||||||
@@ -341,9 +351,11 @@ mod tests {
|
|||||||
drop(b);
|
drop(b);
|
||||||
|
|
||||||
// If b's destructor correctly ran correctly we can now add an edge from c to a.
|
// If b's destructor correctly ran correctly we can now add an edge from c to a.
|
||||||
assert!(get_dependency_graph()
|
assert!(
|
||||||
|
get_dependency_graph()
|
||||||
.add_edge(c.value(), a.value(), Dep::capture)
|
.add_edge(c.value(), a.value(), Dep::capture)
|
||||||
.is_ok());
|
.is_ok()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Test creating a cycle, then panicking.
|
/// Test creating a cycle, then panicking.
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
//! Wrapped mutexes are at least one `usize` larger than the types they wrapped, and must be aligned
|
//! Wrapped mutexes are at least one `usize` larger than the types they wrapped, and must be aligned
|
||||||
//! to `usize` boundaries. As such, libraries with many mutexes may want to consider the additional
|
//! to `usize` boundaries. As such, libraries with many mutexes may want to consider the additional
|
||||||
//! required memory.
|
//! required memory.
|
||||||
|
pub use lock_api as raw;
|
||||||
use lock_api::GuardNoSend;
|
use lock_api::GuardNoSend;
|
||||||
use lock_api::RawMutex;
|
use lock_api::RawMutex;
|
||||||
use lock_api::RawMutexFair;
|
use lock_api::RawMutexFair;
|
||||||
@@ -23,9 +24,9 @@ use lock_api::RawRwLockUpgradeDowngrade;
|
|||||||
use lock_api::RawRwLockUpgradeFair;
|
use lock_api::RawRwLockUpgradeFair;
|
||||||
use lock_api::RawRwLockUpgradeTimed;
|
use lock_api::RawRwLockUpgradeTimed;
|
||||||
|
|
||||||
use crate::util::PrivateTraced;
|
|
||||||
use crate::LazyMutexId;
|
use crate::LazyMutexId;
|
||||||
use crate::MutexId;
|
use crate::MutexId;
|
||||||
|
use crate::util::PrivateTraced;
|
||||||
|
|
||||||
/// Tracing wrapper for all [`lock_api`] traits.
|
/// Tracing wrapper for all [`lock_api`] traits.
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -49,18 +49,18 @@ pub mod tracing;
|
|||||||
|
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
pub use tracing::{
|
pub use tracing::{
|
||||||
const_fair_mutex, const_mutex, const_reentrant_mutex, const_rwlock, FairMutex, FairMutexGuard,
|
FairMutex, FairMutexGuard, MappedFairMutexGuard, MappedMutexGuard, MappedReentrantMutexGuard,
|
||||||
MappedFairMutexGuard, MappedMutexGuard, MappedReentrantMutexGuard, MappedRwLockReadGuard,
|
MappedRwLockReadGuard, MappedRwLockWriteGuard, Mutex, MutexGuard, Once, RawFairMutex, RawMutex,
|
||||||
MappedRwLockWriteGuard, Mutex, MutexGuard, Once, RawFairMutex, RawMutex, RawRwLock,
|
RawRwLock, ReentrantMutex, ReentrantMutexGuard, RwLock, RwLockReadGuard,
|
||||||
ReentrantMutex, ReentrantMutexGuard, RwLock, RwLockReadGuard, RwLockUpgradableReadGuard,
|
RwLockUpgradableReadGuard, RwLockWriteGuard, const_fair_mutex, const_mutex,
|
||||||
RwLockWriteGuard,
|
const_reentrant_mutex, const_rwlock,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(not(debug_assertions))]
|
#[cfg(not(debug_assertions))]
|
||||||
pub use parking_lot::{
|
pub use parking_lot::{
|
||||||
const_fair_mutex, const_mutex, const_reentrant_mutex, const_rwlock, FairMutex, FairMutexGuard,
|
FairMutex, FairMutexGuard, MappedFairMutexGuard, MappedMutexGuard, MappedReentrantMutexGuard,
|
||||||
MappedFairMutexGuard, MappedMutexGuard, MappedReentrantMutexGuard, MappedRwLockReadGuard,
|
MappedRwLockReadGuard, MappedRwLockWriteGuard, Mutex, MutexGuard, Once, RawFairMutex, RawMutex,
|
||||||
MappedRwLockWriteGuard, Mutex, MutexGuard, Once, RawFairMutex, RawMutex, RawRwLock,
|
RawRwLock, ReentrantMutex, ReentrantMutexGuard, RwLock, RwLockReadGuard,
|
||||||
ReentrantMutex, ReentrantMutexGuard, RwLock, RwLockReadGuard, RwLockUpgradableReadGuard,
|
RwLockUpgradableReadGuard, RwLockWriteGuard, const_fair_mutex, const_mutex,
|
||||||
RwLockWriteGuard,
|
const_reentrant_mutex, const_rwlock,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
pub use parking_lot::OnceState;
|
pub use parking_lot::OnceState;
|
||||||
pub use parking_lot::RawThreadId;
|
pub use parking_lot::RawThreadId;
|
||||||
|
|
||||||
use crate::lockapi::TracingWrapper;
|
|
||||||
use crate::LazyMutexId;
|
use crate::LazyMutexId;
|
||||||
|
use crate::lockapi::TracingWrapper;
|
||||||
|
|
||||||
pub type RawFairMutex = TracingWrapper<::parking_lot::RawFairMutex>;
|
pub type RawFairMutex = TracingWrapper<::parking_lot::RawFairMutex>;
|
||||||
pub type RawMutex = TracingWrapper<::parking_lot::RawMutex>;
|
pub type RawMutex = TracingWrapper<::parking_lot::RawMutex>;
|
||||||
|
|||||||
@@ -10,9 +10,9 @@ use std::sync::TryLockResult;
|
|||||||
use std::sync::WaitTimeoutResult;
|
use std::sync::WaitTimeoutResult;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use crate::util::PrivateTraced;
|
|
||||||
use crate::BorrowedMutex;
|
use crate::BorrowedMutex;
|
||||||
use crate::LazyMutexId;
|
use crate::LazyMutexId;
|
||||||
|
use crate::util::PrivateTraced;
|
||||||
|
|
||||||
#[cfg(has_std__sync__LazyLock)]
|
#[cfg(has_std__sync__LazyLock)]
|
||||||
pub use lazy_lock::LazyLock;
|
pub use lazy_lock::LazyLock;
|
||||||
|
|||||||
Reference in New Issue
Block a user