From 22ffed707f9cc89f4cc73ddb1c0e2bfc2881f00a Mon Sep 17 00:00:00 2001 From: 4lDO2 <4lDO2@protonmail.com> Date: Wed, 12 Apr 2023 17:33:38 +0200 Subject: [PATCH] Fix embarrasing deadlock! --- src/sync/mod.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/sync/mod.rs b/src/sync/mod.rs index 6c7b4a5b6a..9e3dd4378a 100644 --- a/src/sync/mod.rs +++ b/src/sync/mod.rs @@ -35,7 +35,7 @@ pub trait FutexTy { pub trait FutexAtomicTy { type Ty: FutexTy; - fn as_mut_ptr(&self) -> *mut Self::Ty; + fn ptr(&self) -> *mut Self::Ty; } impl FutexTy for u32 { fn conv(self) -> i32 { @@ -50,15 +50,15 @@ impl FutexTy for i32 { impl FutexAtomicTy for AtomicU32 { type Ty = u32; - fn as_mut_ptr(&self) -> *mut u32 { - AtomicU32::as_mut_ptr(self) + fn ptr(&self) -> *mut u32 { + AtomicU32::as_ptr(self) } } impl FutexAtomicTy for AtomicI32 { type Ty = i32; - fn as_mut_ptr(&self) -> *mut i32 { - AtomicI32::as_mut_ptr(self) + fn ptr(&self) -> *mut i32 { + AtomicI32::as_ptr(self) } } @@ -71,10 +71,10 @@ pub unsafe fn futex_wait_ptr(ptr: *mut T, value: T, timeout_opt: Opt Sys::futex(ptr.cast(), FUTEX_WAIT, value.conv(), timeout_opt.map_or(0, |t| t as *const _ as usize)) == Ok(0) } pub fn futex_wake(atomic: &impl FutexAtomicTy, n: i32) -> usize { - unsafe { futex_wake_ptr(atomic.as_mut_ptr(), n) } + unsafe { futex_wake_ptr(atomic.ptr(), n) } } pub fn futex_wait(atomic: &T, value: T::Ty, timeout_opt: Option<×pec>) -> bool { - unsafe { futex_wait_ptr(atomic.as_mut_ptr(), value, timeout_opt) } + unsafe { futex_wait_ptr(atomic.ptr(), value, timeout_opt) } } pub fn wait_until_generic(word: &AtomicInt, attempt: F1, mark_long: F2, long: c_int) where