Skip to content

Commit d8dbe60

Browse files
committed
Remove unused experimental deadlock feature
1 parent 96652a8 commit d8dbe60

File tree

5 files changed

+1
-54
lines changed

5 files changed

+1
-54
lines changed

src/libstd/sys_common/parking_lot/condvar.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
use sys_common::parking_lot_core::{
99
self,
10-
deadlock,
1110
ParkResult,
1211
RequeueOp,
1312
UnparkResult,
@@ -306,9 +305,7 @@ impl Condvar {
306305
}
307306

308307
// ... and re-lock it once we are done sleeping
309-
if result == ParkResult::Unparked(TOKEN_HANDOFF) {
310-
deadlock::acquire_resource(mutex as *const _ as usize);
311-
} else {
308+
if result != ParkResult::Unparked(TOKEN_HANDOFF) {
312309
mutex.lock();
313310
}
314311

src/libstd/sys_common/parking_lot/raw_mutex.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ use sync::atomic::{Ordering, AtomicU8, ATOMIC_U8_INIT};
99
use time::Instant;
1010
use super::super::parking_lot_core::{
1111
self,
12-
deadlock,
1312
ParkResult,
1413
SpinWait,
1514
UnparkResult,
@@ -49,7 +48,6 @@ impl RawMutex {
4948
{
5049
self.lock_slow(None);
5150
}
52-
unsafe { deadlock::acquire_resource(self as *const _ as usize) };
5351
}
5452

5553
/// Attempts to acquire this mutex without blocking.
@@ -67,7 +65,6 @@ impl RawMutex {
6765
Ordering::Relaxed,
6866
) {
6967
Ok(_) => {
70-
unsafe { deadlock::acquire_resource(self as *const _ as usize) };
7168
return true;
7269
}
7370
Err(x) => state = x,
@@ -78,7 +75,6 @@ impl RawMutex {
7875
/// Unlocks this mutex.
7976
#[inline]
8077
pub fn unlock(&self) {
81-
unsafe { deadlock::release_resource(self as *const _ as usize) };
8278
if self
8379
.state
8480
.compare_exchange_weak(LOCKED_BIT, 0, Ordering::Release, Ordering::Relaxed)

src/libstd/sys_common/parking_lot/raw_rwlock.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use super::elision::{have_elision, AtomicElisionExt};
99
use super::super::parking_lot_core::{
1010
self,
11-
deadlock,
1211
FilterOp,
1312
ParkResult,
1413
ParkToken,
@@ -59,7 +58,6 @@ impl RawRwLock {
5958
let result = self.lock_exclusive_slow(None);
6059
debug_assert!(result);
6160
}
62-
unsafe { deadlock::acquire_resource(self as *const _ as usize) };
6361
}
6462

6563
/// Attempts to acquire an exclusive lock without blocking.
@@ -70,7 +68,6 @@ impl RawRwLock {
7068
.compare_exchange(0, EXCLUSIVE_GUARD, Ordering::Acquire, Ordering::Relaxed)
7169
.is_ok()
7270
{
73-
unsafe { deadlock::acquire_resource(self as *const _ as usize) };
7471
true
7572
} else {
7673
false
@@ -80,7 +77,6 @@ impl RawRwLock {
8077
/// Releases an exclusive lock.
8178
#[inline]
8279
pub fn unlock_exclusive(&self) {
83-
unsafe { deadlock::release_resource(self as *const _ as usize) };
8480
if self
8581
.state
8682
.compare_exchange_weak(EXCLUSIVE_GUARD, 0, Ordering::Release, Ordering::Relaxed)
@@ -98,7 +94,6 @@ impl RawRwLock {
9894
let result = self.lock_shared_slow(false, None);
9995
debug_assert!(result);
10096
}
101-
unsafe { deadlock::acquire_resource(self as *const _ as usize) };
10297
}
10398

10499
/// Attempts to acquire a shared lock without blocking.
@@ -109,16 +104,12 @@ impl RawRwLock {
109104
} else {
110105
self.try_lock_shared_slow(false)
111106
};
112-
if result {
113-
unsafe { deadlock::acquire_resource(self as *const _ as usize) };
114-
}
115107
result
116108
}
117109

118110
/// Releases a shared lock.
119111
#[inline]
120112
pub fn unlock_shared(&self) {
121-
unsafe { deadlock::release_resource(self as *const _ as usize) };
122113
let state = self.state.load(Ordering::Relaxed);
123114
if state & PARKED_BIT == 0
124115
|| (state & UPGRADING_BIT == 0 && state & GUARD_COUNT_MASK != SHARED_GUARD)

src/libstd/sys_common/parking_lot_core/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ mod spinwait;
4343
mod util;
4444
mod word_lock;
4545

46-
pub use self::parking_lot::deadlock;
4746
pub use self::parking_lot::{park, unpark_filter, unpark_one, unpark_requeue};
4847
pub use self::parking_lot::{FilterOp, ParkResult, ParkToken, RequeueOp, UnparkResult, UnparkToken};
4948
pub use self::parking_lot::{DEFAULT_PARK_TOKEN, DEFAULT_UNPARK_TOKEN};

src/libstd/sys_common/parking_lot_core/parking_lot.rs

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,6 @@ struct ThreadData {
125125

126126
// Is the thread parked with a timeout?
127127
parked_with_timeout: Cell<bool>,
128-
129-
// Extra data for deadlock detection
130-
// FIXME: once supported in stable replace with #[cfg...] & remove dummy struct/impl
131-
#[allow(dead_code)]
132-
deadlock_data: deadlock::DeadlockData,
133128
}
134129

135130
impl ThreadData {
@@ -148,7 +143,6 @@ impl ThreadData {
148143
unpark_token: Cell::new(DEFAULT_UNPARK_TOKEN),
149144
park_token: Cell::new(DEFAULT_PARK_TOKEN),
150145
parked_with_timeout: Cell::new(false),
151-
deadlock_data: deadlock::DeadlockData::new(),
152146
}
153147
}
154148
}
@@ -601,8 +595,6 @@ unsafe fn park_internal(
601595
Some(timeout) => thread_data.parker.park_until(timeout),
602596
None => {
603597
thread_data.parker.park();
604-
// call deadlock detection on_unpark hook
605-
deadlock::on_unpark(thread_data);
606598
true
607599
}
608600
};
@@ -1020,31 +1012,3 @@ unsafe fn unpark_filter_internal(
10201012

10211013
result
10221014
}
1023-
1024-
/// Just not supported when in libstd.
1025-
pub mod deadlock {
1026-
pub(super) struct DeadlockData {}
1027-
1028-
impl DeadlockData {
1029-
pub(super) fn new() -> Self {
1030-
DeadlockData {}
1031-
}
1032-
}
1033-
1034-
/// Acquire a resource identified by key in the deadlock detector
1035-
/// Noop if deadlock_detection feature isn't enabled.
1036-
/// Note: Call after the resource is acquired
1037-
#[inline]
1038-
pub unsafe fn acquire_resource(_key: usize) {}
1039-
1040-
/// Release a resource identified by key in the deadlock detector.
1041-
/// Noop if deadlock_detection feature isn't enabled.
1042-
/// Note: Call before the resource is released
1043-
/// # Panics
1044-
/// Panics if the resource was already released or wasn't acquired in this thread.
1045-
#[inline]
1046-
pub unsafe fn release_resource(_key: usize) {}
1047-
1048-
#[inline]
1049-
pub(super) unsafe fn on_unpark(_td: &super::ThreadData) {}
1050-
}

0 commit comments

Comments
 (0)