@@ -9,6 +9,7 @@ use crate::sync::Arc;
9
9
/// A scope to spawn scoped threads in.
10
10
///
11
11
/// See [`scope`] for details.
12
+ #[ stable( feature = "scoped_threads" , since = "1.63.0" ) ]
12
13
pub struct Scope < ' scope , ' env : ' scope > {
13
14
data : ScopeData ,
14
15
/// Invariance over 'scope, to make sure 'scope cannot shrink,
@@ -17,8 +18,6 @@ pub struct Scope<'scope, 'env: 'scope> {
17
18
/// Without invariance, this would compile fine but be unsound:
18
19
///
19
20
/// ```compile_fail,E0373
20
- /// #![feature(scoped_threads)]
21
- ///
22
21
/// std::thread::scope(|s| {
23
22
/// s.spawn(|| {
24
23
/// let a = String::from("abcd");
@@ -33,6 +32,7 @@ pub struct Scope<'scope, 'env: 'scope> {
33
32
/// An owned permission to join on a scoped thread (block on its termination).
34
33
///
35
34
/// See [`Scope::spawn`] for details.
35
+ #[ stable( feature = "scoped_threads" , since = "1.63.0" ) ]
36
36
pub struct ScopedJoinHandle < ' scope , T > ( JoinInner < ' scope , T > ) ;
37
37
38
38
pub ( super ) struct ScopeData {
@@ -82,7 +82,6 @@ impl ScopeData {
82
82
/// # Example
83
83
///
84
84
/// ```
85
- /// #![feature(scoped_threads)]
86
85
/// use std::thread;
87
86
///
88
87
/// let mut a = vec![1, 2, 3];
@@ -126,6 +125,7 @@ impl ScopeData {
126
125
///
127
126
/// The `'env: 'scope` bound is part of the definition of the `Scope` type.
128
127
#[ track_caller]
128
+ #[ stable( feature = "scoped_threads" , since = "1.63.0" ) ]
129
129
pub fn scope < ' env , F , T > ( f : F ) -> T
130
130
where
131
131
F : for < ' scope > FnOnce ( & ' scope Scope < ' scope , ' env > ) -> T ,
@@ -183,6 +183,7 @@ impl<'scope, 'env> Scope<'scope, 'env> {
183
183
/// to recover from such errors.
184
184
///
185
185
/// [`join`]: ScopedJoinHandle::join
186
+ #[ stable( feature = "scoped_threads" , since = "1.63.0" ) ]
186
187
pub fn spawn < F , T > ( & ' scope self , f : F ) -> ScopedJoinHandle < ' scope , T >
187
188
where
188
189
F : FnOnce ( ) -> T + Send + ' scope ,
@@ -207,7 +208,6 @@ impl Builder {
207
208
/// # Example
208
209
///
209
210
/// ```
210
- /// #![feature(scoped_threads)]
211
211
/// use std::thread;
212
212
///
213
213
/// let mut a = vec![1, 2, 3];
@@ -240,6 +240,7 @@ impl Builder {
240
240
/// a.push(4);
241
241
/// assert_eq!(x, a.len());
242
242
/// ```
243
+ #[ stable( feature = "scoped_threads" , since = "1.63.0" ) ]
243
244
pub fn spawn_scoped < ' scope , ' env , F , T > (
244
245
self ,
245
246
scope : & ' scope Scope < ' scope , ' env > ,
@@ -259,8 +260,6 @@ impl<'scope, T> ScopedJoinHandle<'scope, T> {
259
260
/// # Examples
260
261
///
261
262
/// ```
262
- /// #![feature(scoped_threads)]
263
- ///
264
263
/// use std::thread;
265
264
///
266
265
/// thread::scope(|s| {
@@ -271,6 +270,7 @@ impl<'scope, T> ScopedJoinHandle<'scope, T> {
271
270
/// });
272
271
/// ```
273
272
#[ must_use]
273
+ #[ stable( feature = "scoped_threads" , since = "1.63.0" ) ]
274
274
pub fn thread ( & self ) -> & Thread {
275
275
& self . 0 . thread
276
276
}
@@ -292,8 +292,6 @@ impl<'scope, T> ScopedJoinHandle<'scope, T> {
292
292
/// # Examples
293
293
///
294
294
/// ```
295
- /// #![feature(scoped_threads)]
296
- ///
297
295
/// use std::thread;
298
296
///
299
297
/// thread::scope(|s| {
@@ -303,6 +301,7 @@ impl<'scope, T> ScopedJoinHandle<'scope, T> {
303
301
/// assert!(t.join().is_err());
304
302
/// });
305
303
/// ```
304
+ #[ stable( feature = "scoped_threads" , since = "1.63.0" ) ]
306
305
pub fn join ( self ) -> Result < T > {
307
306
self . 0 . join ( )
308
307
}
@@ -316,11 +315,13 @@ impl<'scope, T> ScopedJoinHandle<'scope, T> {
316
315
///
317
316
/// This function does not block. To block while waiting on the thread to finish,
318
317
/// use [`join`][Self::join].
318
+ #[ stable( feature = "scoped_threads" , since = "1.63.0" ) ]
319
319
pub fn is_finished ( & self ) -> bool {
320
320
Arc :: strong_count ( & self . 0 . packet ) == 1
321
321
}
322
322
}
323
323
324
+ #[ stable( feature = "scoped_threads" , since = "1.63.0" ) ]
324
325
impl fmt:: Debug for Scope < ' _ , ' _ > {
325
326
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
326
327
f. debug_struct ( "Scope" )
@@ -331,6 +332,7 @@ impl fmt::Debug for Scope<'_, '_> {
331
332
}
332
333
}
333
334
335
+ #[ stable( feature = "scoped_threads" , since = "1.63.0" ) ]
334
336
impl < ' scope , T > fmt:: Debug for ScopedJoinHandle < ' scope , T > {
335
337
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
336
338
f. debug_struct ( "ScopedJoinHandle" ) . finish_non_exhaustive ( )
0 commit comments