@@ -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" ) ]
1213pub 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" ) ]
3636pub struct ScopedJoinHandle < ' scope , T > ( JoinInner < ' scope , T > ) ;
3737
3838pub ( 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" ) ]
129129pub fn scope < ' env , F , T > ( f : F ) -> T
130130where
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" ) ]
324325impl 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" ) ]
334336impl < ' 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