Skip to content

Commit 58d0d2e

Browse files
authored
Rollup merge of rust-lang#97992 - m-ou-se:stabilize-scoped-threads, r=joshtriplett
Stabilize scoped threads. Tracking issue: rust-lang#93203 FCP finished here: rust-lang#93203 (comment)
2 parents 13bfefc + ae0a533 commit 58d0d2e

File tree

3 files changed

+18
-16
lines changed

3 files changed

+18
-16
lines changed

library/core/src/sync/atomic.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ impl AtomicBool {
350350
/// # Examples
351351
///
352352
/// ```
353-
/// #![feature(atomic_from_mut, inline_const, scoped_threads)]
353+
/// #![feature(atomic_from_mut, inline_const)]
354354
/// use std::sync::atomic::{AtomicBool, Ordering};
355355
///
356356
/// let mut some_bools = [const { AtomicBool::new(false) }; 10];
@@ -381,7 +381,7 @@ impl AtomicBool {
381381
/// # Examples
382382
///
383383
/// ```
384-
/// #![feature(atomic_from_mut, scoped_threads)]
384+
/// #![feature(atomic_from_mut)]
385385
/// use std::sync::atomic::{AtomicBool, Ordering};
386386
///
387387
/// let mut some_bools = [false; 10];
@@ -1015,7 +1015,7 @@ impl<T> AtomicPtr<T> {
10151015
/// # Examples
10161016
///
10171017
/// ```
1018-
/// #![feature(atomic_from_mut, inline_const, scoped_threads)]
1018+
/// #![feature(atomic_from_mut, inline_const)]
10191019
/// use std::ptr::null_mut;
10201020
/// use std::sync::atomic::{AtomicPtr, Ordering};
10211021
///
@@ -1052,7 +1052,7 @@ impl<T> AtomicPtr<T> {
10521052
/// # Examples
10531053
///
10541054
/// ```
1055-
/// #![feature(atomic_from_mut, scoped_threads)]
1055+
/// #![feature(atomic_from_mut)]
10561056
/// use std::ptr::null_mut;
10571057
/// use std::sync::atomic::{AtomicPtr, Ordering};
10581058
///
@@ -1607,7 +1607,7 @@ macro_rules! atomic_int {
16071607
/// # Examples
16081608
///
16091609
/// ```
1610-
/// #![feature(atomic_from_mut, inline_const, scoped_threads)]
1610+
/// #![feature(atomic_from_mut, inline_const)]
16111611
#[doc = concat!($extra_feature, "use std::sync::atomic::{", stringify!($atomic_type), ", Ordering};")]
16121612
///
16131613
#[doc = concat!("let mut some_ints = [const { ", stringify!($atomic_type), "::new(0) }; 10];")]
@@ -1640,7 +1640,7 @@ macro_rules! atomic_int {
16401640
/// # Examples
16411641
///
16421642
/// ```
1643-
/// #![feature(atomic_from_mut, scoped_threads)]
1643+
/// #![feature(atomic_from_mut)]
16441644
#[doc = concat!($extra_feature, "use std::sync::atomic::{", stringify!($atomic_type), ", Ordering};")]
16451645
///
16461646
/// let mut some_ints = [0; 10];

library/std/src/thread/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,10 @@ use crate::time::Duration;
183183
#[macro_use]
184184
mod local;
185185

186-
#[unstable(feature = "scoped_threads", issue = "93203")]
186+
#[stable(feature = "scoped_threads", since = "1.63.0")]
187187
mod scoped;
188188

189-
#[unstable(feature = "scoped_threads", issue = "93203")]
189+
#[stable(feature = "scoped_threads", since = "1.63.0")]
190190
pub use scoped::{scope, Scope, ScopedJoinHandle};
191191

192192
#[stable(feature = "rust1", since = "1.0.0")]

library/std/src/thread/scoped.rs

+10-8
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use crate::sync::Arc;
99
/// A scope to spawn scoped threads in.
1010
///
1111
/// See [`scope`] for details.
12+
#[stable(feature = "scoped_threads", since = "1.63.0")]
1213
pub struct Scope<'scope, 'env: 'scope> {
1314
data: ScopeData,
1415
/// Invariance over 'scope, to make sure 'scope cannot shrink,
@@ -17,8 +18,6 @@ pub struct Scope<'scope, 'env: 'scope> {
1718
/// Without invariance, this would compile fine but be unsound:
1819
///
1920
/// ```compile_fail,E0373
20-
/// #![feature(scoped_threads)]
21-
///
2221
/// std::thread::scope(|s| {
2322
/// s.spawn(|| {
2423
/// let a = String::from("abcd");
@@ -33,6 +32,7 @@ pub struct Scope<'scope, 'env: 'scope> {
3332
/// An owned permission to join on a scoped thread (block on its termination).
3433
///
3534
/// See [`Scope::spawn`] for details.
35+
#[stable(feature = "scoped_threads", since = "1.63.0")]
3636
pub struct ScopedJoinHandle<'scope, T>(JoinInner<'scope, T>);
3737

3838
pub(super) struct ScopeData {
@@ -82,7 +82,6 @@ impl ScopeData {
8282
/// # Example
8383
///
8484
/// ```
85-
/// #![feature(scoped_threads)]
8685
/// use std::thread;
8786
///
8887
/// let mut a = vec![1, 2, 3];
@@ -126,6 +125,7 @@ impl ScopeData {
126125
///
127126
/// The `'env: 'scope` bound is part of the definition of the `Scope` type.
128127
#[track_caller]
128+
#[stable(feature = "scoped_threads", since = "1.63.0")]
129129
pub fn scope<'env, F, T>(f: F) -> T
130130
where
131131
F: for<'scope> FnOnce(&'scope Scope<'scope, 'env>) -> T,
@@ -183,6 +183,7 @@ impl<'scope, 'env> Scope<'scope, 'env> {
183183
/// to recover from such errors.
184184
///
185185
/// [`join`]: ScopedJoinHandle::join
186+
#[stable(feature = "scoped_threads", since = "1.63.0")]
186187
pub fn spawn<F, T>(&'scope self, f: F) -> ScopedJoinHandle<'scope, T>
187188
where
188189
F: FnOnce() -> T + Send + 'scope,
@@ -207,7 +208,6 @@ impl Builder {
207208
/// # Example
208209
///
209210
/// ```
210-
/// #![feature(scoped_threads)]
211211
/// use std::thread;
212212
///
213213
/// let mut a = vec![1, 2, 3];
@@ -240,6 +240,7 @@ impl Builder {
240240
/// a.push(4);
241241
/// assert_eq!(x, a.len());
242242
/// ```
243+
#[stable(feature = "scoped_threads", since = "1.63.0")]
243244
pub fn spawn_scoped<'scope, 'env, F, T>(
244245
self,
245246
scope: &'scope Scope<'scope, 'env>,
@@ -259,8 +260,6 @@ impl<'scope, T> ScopedJoinHandle<'scope, T> {
259260
/// # Examples
260261
///
261262
/// ```
262-
/// #![feature(scoped_threads)]
263-
///
264263
/// use std::thread;
265264
///
266265
/// thread::scope(|s| {
@@ -271,6 +270,7 @@ impl<'scope, T> ScopedJoinHandle<'scope, T> {
271270
/// });
272271
/// ```
273272
#[must_use]
273+
#[stable(feature = "scoped_threads", since = "1.63.0")]
274274
pub fn thread(&self) -> &Thread {
275275
&self.0.thread
276276
}
@@ -292,8 +292,6 @@ impl<'scope, T> ScopedJoinHandle<'scope, T> {
292292
/// # Examples
293293
///
294294
/// ```
295-
/// #![feature(scoped_threads)]
296-
///
297295
/// use std::thread;
298296
///
299297
/// thread::scope(|s| {
@@ -303,6 +301,7 @@ impl<'scope, T> ScopedJoinHandle<'scope, T> {
303301
/// assert!(t.join().is_err());
304302
/// });
305303
/// ```
304+
#[stable(feature = "scoped_threads", since = "1.63.0")]
306305
pub fn join(self) -> Result<T> {
307306
self.0.join()
308307
}
@@ -316,11 +315,13 @@ impl<'scope, T> ScopedJoinHandle<'scope, T> {
316315
///
317316
/// This function does not block. To block while waiting on the thread to finish,
318317
/// use [`join`][Self::join].
318+
#[stable(feature = "scoped_threads", since = "1.63.0")]
319319
pub fn is_finished(&self) -> bool {
320320
Arc::strong_count(&self.0.packet) == 1
321321
}
322322
}
323323

324+
#[stable(feature = "scoped_threads", since = "1.63.0")]
324325
impl fmt::Debug for Scope<'_, '_> {
325326
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
326327
f.debug_struct("Scope")
@@ -331,6 +332,7 @@ impl fmt::Debug for Scope<'_, '_> {
331332
}
332333
}
333334

335+
#[stable(feature = "scoped_threads", since = "1.63.0")]
334336
impl<'scope, T> fmt::Debug for ScopedJoinHandle<'scope, T> {
335337
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
336338
f.debug_struct("ScopedJoinHandle").finish_non_exhaustive()

0 commit comments

Comments
 (0)