diff options
| author | joboet <jonasboettiger@icloud.com> | 2022-12-29 17:54:09 +0100 |
|---|---|---|
| committer | joboet <jonasboettiger@icloud.com> | 2022-12-29 17:54:09 +0100 |
| commit | 3076f4ec30632a063d0737bef589e1c4859ad23c (patch) | |
| tree | 8198c5469f8c0131175a8d79474f207a8994ba92 /library/std/src | |
| parent | a9e5c1a309df80434ebc4c1f6bfaa5cb119b465d (diff) | |
| download | rust-3076f4ec30632a063d0737bef589e1c4859ad23c.tar.gz rust-3076f4ec30632a063d0737bef589e1c4859ad23c.zip | |
std: pass hint to id-based parking functions
Diffstat (limited to 'library/std/src')
| -rw-r--r-- | library/std/src/sys/sgx/thread_parking.rs | 6 | ||||
| -rw-r--r-- | library/std/src/sys/unix/thread_parking/netbsd.rs | 14 | ||||
| -rw-r--r-- | library/std/src/sys_common/thread_parking/id.rs | 6 |
3 files changed, 13 insertions, 13 deletions
diff --git a/library/std/src/sys/sgx/thread_parking.rs b/library/std/src/sys/sgx/thread_parking.rs index a1795c358d6..0006cd4f1be 100644 --- a/library/std/src/sys/sgx/thread_parking.rs +++ b/library/std/src/sys/sgx/thread_parking.rs @@ -7,17 +7,17 @@ pub type ThreadId = fortanix_sgx_abi::Tcs; pub use super::abi::thread::current; -pub fn park() { +pub fn park(_hint: usize) { usercalls::wait(EV_UNPARK, WAIT_INDEFINITE).unwrap(); } -pub fn park_timeout(dur: Duration) { +pub fn park_timeout(dur: Duration, _hint: usize) { let timeout = u128::min(dur.as_nanos(), WAIT_INDEFINITE as u128 - 1) as u64; if let Err(e) = usercalls::wait(EV_UNPARK, timeout) { assert!(matches!(e.kind(), ErrorKind::TimedOut | ErrorKind::WouldBlock)) } } -pub fn unpark(tid: ThreadId) { +pub fn unpark(tid: ThreadId, _hint: usize) { let _ = usercalls::send(EV_UNPARK, Some(tid)); } diff --git a/library/std/src/sys/unix/thread_parking/netbsd.rs b/library/std/src/sys/unix/thread_parking/netbsd.rs index a441a05da0f..7107ff733bd 100644 --- a/library/std/src/sys/unix/thread_parking/netbsd.rs +++ b/library/std/src/sys/unix/thread_parking/netbsd.rs @@ -1,7 +1,7 @@ #![cfg(target_os = "netbsd")] use crate::ffi::{c_int, c_void}; -use crate::ptr::{null, null_mut}; +use crate::ptr; use crate::time::Duration; use libc::{_lwp_self, clockid_t, lwpid_t, time_t, timespec, CLOCK_MONOTONIC}; @@ -25,13 +25,13 @@ pub fn current() -> ThreadId { } #[inline] -pub fn park() { +pub fn park(hint: usize) { unsafe { - ___lwp_park60(0, 0, null_mut(), 0, null(), null()); + ___lwp_park60(0, 0, ptr::null_mut(), 0, ptr::invalid(hint), ptr::null()); } } -pub fn park_timeout(dur: Duration) { +pub fn park_timeout(dur: Duration, hint: usize) { let mut timeout = timespec { // Saturate so that the operation will definitely time out // (even if it is after the heat death of the universe). @@ -42,13 +42,13 @@ pub fn park_timeout(dur: Duration) { // Timeout needs to be mutable since it is modified on NetBSD 9.0 and // above. unsafe { - ___lwp_park60(CLOCK_MONOTONIC, 0, &mut timeout, 0, null(), null()); + ___lwp_park60(CLOCK_MONOTONIC, 0, &mut timeout, 0, ptr::invalid(hint), ptr::null()); } } #[inline] -pub fn unpark(tid: ThreadId) { +pub fn unpark(tid: ThreadId, hint: usize) { unsafe { - _lwp_unpark(tid, null()); + _lwp_unpark(tid, ptr::invalid(hint)); } } diff --git a/library/std/src/sys_common/thread_parking/id.rs b/library/std/src/sys_common/thread_parking/id.rs index 9525340b75f..32e2195b808 100644 --- a/library/std/src/sys_common/thread_parking/id.rs +++ b/library/std/src/sys_common/thread_parking/id.rs @@ -56,7 +56,7 @@ impl Parker { if state == PARKED { // Loop to guard against spurious wakeups. while state == PARKED { - park(); + park(self.state.as_mut_ptr().addr()); state = self.state.load(Acquire); } @@ -72,7 +72,7 @@ impl Parker { let state = self.state.fetch_sub(1, Acquire).wrapping_sub(1); if state == PARKED { - park_timeout(dur); + park_timeout(dur, self.state.as_mut_ptr().addr()); // Swap to ensure that we observe all state changes with acquire // ordering, even if the state has been changed after the timeout // occured. @@ -95,7 +95,7 @@ impl Parker { // and terminated before this call is made. This call then returns an // error or wakes up an unrelated thread. The platform API and // environment does allow this, however. - unpark(tid); + unpark(tid, self.state.as_mut_ptr().addr()); } } } |
