Skip to content

Commit 922aef0

Browse files
committed
Auto merge of #27311 - kballard:thread-mod-desc-remove-scoped, r=huonw
It's deprecated and unsafe, so we shouldn't be encouraging people to use it. Move it to `std::thread::scoped` instead, since it's still useful information to anyone who is using the API.
2 parents 6d28819 + 11c2218 commit 922aef0

File tree

1 file changed

+25
-34
lines changed

1 file changed

+25
-34
lines changed

src/libstd/thread/mod.rs

+25-34
Original file line numberDiff line numberDiff line change
@@ -85,33 +85,6 @@
8585
//! value produced by the child thread, or `Err` of the value given to
8686
//! a call to `panic!` if the child panicked.
8787
//!
88-
//! ## Scoped threads
89-
//!
90-
//! The `spawn` method does not allow the child and parent threads to
91-
//! share any stack data, since that is not safe in general. However,
92-
//! `scoped` makes it possible to share the parent's stack by forcing
93-
//! a join before any relevant stack frames are popped:
94-
//!
95-
//! ```rust
96-
//! # #![feature(scoped)]
97-
//! use std::thread;
98-
//!
99-
//! let guard = thread::scoped(move || {
100-
//! // some work here
101-
//! });
102-
//!
103-
//! // do some other work in the meantime
104-
//! let output = guard.join();
105-
//! ```
106-
//!
107-
//! The `scoped` function doesn't return a `Thread` directly; instead,
108-
//! it returns a *join guard*. The join guard is an RAII-style guard
109-
//! that will automatically join the child thread (block until it
110-
//! terminates) when it is dropped. You can join the child thread in
111-
//! advance by calling the `join` method on the guard, which will also
112-
//! return the result produced by the thread. A handle to the thread
113-
//! itself is available via the `thread` method of the join guard.
114-
//!
11588
//! ## Configuring threads
11689
//!
11790
//! A new thread can be configured before it is spawned via the `Builder` type,
@@ -288,7 +261,7 @@ impl Builder {
288261
/// upon being dropped. Because the child thread may refer to data on the
289262
/// current thread's stack (hence the "scoped" name), it cannot be detached;
290263
/// it *must* be joined before the relevant stack frame is popped. See the
291-
/// module documentation for additional details.
264+
/// documentation on `thread::scoped` for additional details.
292265
///
293266
/// # Errors
294267
///
@@ -388,12 +361,30 @@ pub fn spawn<F, T>(f: F) -> JoinHandle<T> where
388361

389362
/// Spawns a new *scoped* thread, returning a `JoinGuard` for it.
390363
///
391-
/// The join guard can be used to explicitly join the child thread (via
392-
/// `join`), returning `Result<T>`, or it will implicitly join the child
393-
/// upon being dropped. Because the child thread may refer to data on the
394-
/// current thread's stack (hence the "scoped" name), it cannot be detached;
395-
/// it *must* be joined before the relevant stack frame is popped. See the
396-
/// module documentation for additional details.
364+
/// The `spawn` method does not allow the child and parent threads to
365+
/// share any stack data, since that is not safe in general. However,
366+
/// `scoped` makes it possible to share the parent's stack by forcing
367+
/// a join before any relevant stack frames are popped:
368+
///
369+
/// ```rust
370+
/// # #![feature(scoped)]
371+
/// use std::thread;
372+
///
373+
/// let guard = thread::scoped(move || {
374+
/// // some work here
375+
/// });
376+
///
377+
/// // do some other work in the meantime
378+
/// let output = guard.join();
379+
/// ```
380+
///
381+
/// The `scoped` function doesn't return a `Thread` directly; instead, it
382+
/// returns a *join guard*. The join guard can be used to explicitly join
383+
/// the child thread (via `join`), returning `Result<T>`, or it will
384+
/// implicitly join the child upon being dropped. Because the child thread
385+
/// may refer to data on the current thread's stack (hence the "scoped"
386+
/// name), it cannot be detached; it *must* be joined before the relevant
387+
/// stack frame is popped.
397388
///
398389
/// # Panics
399390
///

0 commit comments

Comments
 (0)