Skip to content

Commit e9ef4a2

Browse files
committed
Remove the lazy_static dependency
It is not necessary anymore. We can initialize the Mutex at compile time.
1 parent b62d1f5 commit e9ef4a2

File tree

3 files changed

+4
-6
lines changed

3 files changed

+4
-6
lines changed

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ lock_api = { path = "lock_api", version = "0.3.1" }
1616

1717
[dev-dependencies]
1818
rand = "0.7"
19-
lazy_static = "1.0"
2019

2120
# Used when testing out serde support.
2221
bincode = {version = "1.1.3"}

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,9 @@ lock.
8787

8888
There are a few restrictions when using this library on stable Rust:
8989

90-
- You will have to use `lazy_static!` or equivalent to statically initialize `Mutex`
91-
and `RwLock` types. They use generics and can't be `const fn`s on stable yet.
90+
- You will have to use the `const_*` functions (e.g. `const_mutex(val)`) to
91+
statically initialize the locking primitives. Using e.g. `Mutex::new(val)`
92+
does not work on stable Rust yet.
9293
- `RwLock` will not be able to take advantage of hardware lock elision for
9394
readers, which improves performance when there are multiple readers.
9495

src/deadlock.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,7 @@ mod tests {
4646
use std::time::Duration;
4747

4848
// We need to serialize these tests since deadlock detection uses global state
49-
lazy_static::lazy_static! {
50-
static ref DEADLOCK_DETECTION_LOCK: Mutex<()> = Mutex::new(());
51-
}
49+
static DEADLOCK_DETECTION_LOCK: Mutex<()> = crate::const_mutex(());
5250

5351
fn check_deadlock() -> bool {
5452
use parking_lot_core::deadlock::check_deadlock;

0 commit comments

Comments
 (0)