Skip to content

Commit faa3169

Browse files
authored
Rollup merge of rust-lang#105695 - joboet:remove_generic_parker, r=m-ou-se
Replace generic thread parker with explicit no-op parker With rust-lang#98391 merged, all platforms supporting threads now have their own parking implementations. Therefore, the generic implementation can be removed. On the remaining platforms (really just WASM without atomics), parking is not supported, so calls to `thread::park` now return instantly, which is [allowed by their API](https://doc.rust-lang.org/nightly/std/thread/fn.park.html). This is a change in behaviour, as spurious wakeups do not currently occur since all platforms guard against them. It is invalid to depend on this, but I'm still going to tag this as libs-api for confirmation. ```@rustbot``` label +T-libs +T-libs-api +A-atomic r? rust-lang/libs
2 parents 3e797ec + 9622cde commit faa3169

File tree

6 files changed

+17
-129
lines changed

6 files changed

+17
-129
lines changed

library/std/src/sys/unsupported/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ pub mod thread;
2222
#[cfg(target_thread_local)]
2323
pub mod thread_local_dtor;
2424
pub mod thread_local_key;
25+
pub mod thread_parking;
2526
pub mod time;
2627

2728
mod common;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
use crate::pin::Pin;
2+
use crate::time::Duration;
3+
4+
pub struct Parker {}
5+
6+
impl Parker {
7+
pub unsafe fn new_in_place(_parker: *mut Parker) {}
8+
pub unsafe fn park(self: Pin<&Self>) {}
9+
pub unsafe fn park_timeout(self: Pin<&Self>, _dur: Duration) {}
10+
pub fn unpark(self: Pin<&Self>) {}
11+
}

library/std/src/sys/wasi/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ pub mod thread;
4747
pub mod thread_local_dtor;
4848
#[path = "../unsupported/thread_local_key.rs"]
4949
pub mod thread_local_key;
50+
#[path = "../unsupported/thread_parking.rs"]
51+
pub mod thread_parking;
5052
pub mod time;
5153

5254
cfg_if::cfg_if! {

library/std/src/sys/wasm/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ cfg_if::cfg_if! {
7070
pub mod once;
7171
#[path = "../unsupported/thread.rs"]
7272
pub mod thread;
73+
#[path = "../unsupported/thread_parking.rs"]
74+
pub mod thread_parking;
7375
}
7476
}
7577

library/std/src/sys_common/thread_parking/generic.rs

-125
This file was deleted.

library/std/src/sys_common/thread_parking/mod.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@ cfg_if::cfg_if! {
1818
))] {
1919
mod id;
2020
pub use id::Parker;
21-
} else if #[cfg(any(windows, target_family = "unix"))] {
22-
pub use crate::sys::thread_parking::Parker;
2321
} else {
24-
mod generic;
25-
pub use generic::Parker;
22+
pub use crate::sys::thread_parking::Parker;
2623
}
2724
}

0 commit comments

Comments
 (0)