Skip to content

Commit 2db90bb

Browse files
committed
Document that the thread may still be running.
1 parent 22bcb92 commit 2db90bb

File tree

2 files changed

+27
-10
lines changed

2 files changed

+27
-10
lines changed

Diff for: library/std/src/thread/mod.rs

+18-7
Original file line numberDiff line numberDiff line change
@@ -1885,11 +1885,16 @@ impl<T> JoinHandle<T> {
18851885
/// Returns a [`Future`] that resolves when the thread has finished.
18861886
///
18871887
/// Its [output](Future::Output) value is identical to that of [`JoinHandle::join()`];
1888-
/// this is the `async` equivalent of that blocking function.
1888+
/// this is the approximate `async` equivalent of that blocking function.
18891889
///
1890-
/// If the returned future is dropped (cancelled), the thread will become *detached*;
1891-
/// there will be no way to observe or wait for the thread’s termination.
1892-
/// This is identical to the behavior of `JoinHandle` itself.
1890+
/// # Details
1891+
///
1892+
/// * If the returned future is dropped (cancelled), the thread will become *detached*;
1893+
/// there will be no way to observe or wait for the thread’s termination.
1894+
/// This is identical to the behavior of `JoinHandle` itself.
1895+
///
1896+
/// * Unlike [`JoinHandle::join()`], the thread may still exist when the future resolves.
1897+
/// In particular, it may still be executing destructors for thread-local values.
18931898
///
18941899
/// # Example
18951900
///
@@ -1970,9 +1975,15 @@ fn _assert_sync_and_send() {
19701975
/// Obtain it by calling [`JoinHandle::into_join_future()`] or
19711976
/// [`ScopedJoinHandle::into_join_future()`].
19721977
///
1973-
/// If a `JoinFuture` is dropped (cancelled), and the thread does not belong to a [scope],
1974-
/// the associated thread will become *detached*;
1975-
/// there will be no way to observe or wait for the thread’s termination.
1978+
/// # Behavior details
1979+
///
1980+
/// * If a `JoinFuture` is dropped (cancelled), and the thread does not belong to a [scope],
1981+
/// the associated thread will become *detached*;
1982+
/// there will be no way to observe or wait for the thread’s termination.
1983+
///
1984+
/// * Unlike [`JoinHandle::join()`], the thread may still exist when the future resolves.
1985+
/// In particular, it may still be executing destructors for thread-local values.
1986+
///
19761987
#[unstable(feature = "thread_join_future", issue = "none")]
19771988
pub struct JoinFuture<'scope, T>(Option<JoinInner<'scope, T>>);
19781989

Diff for: library/std/src/thread/scoped.rs

+9-3
Original file line numberDiff line numberDiff line change
@@ -318,12 +318,18 @@ impl<'scope, T> ScopedJoinHandle<'scope, T> {
318318
/// Its [output] value is identical to that of [`ScopedJoinHandle::join()`];
319319
/// this is the `async` equivalent of that blocking function.
320320
///
321-
/// Note that while this function allows waiting for a scoped thread from `async`
322-
/// functions, the original [`scope()`] is still a blocking function which should
323-
/// not be used in `async` functions.
321+
/// # Behavior details
322+
///
323+
/// * Unlike [`JoinHandle::join()`], the thread may still exist when the future resolves.
324+
/// In particular, it may still be executing destructors for thread-local values.
325+
///
326+
/// * While this function allows waiting for a scoped thread from `async`
327+
/// functions, the original [`scope()`] is still a blocking function which should
328+
/// not be used in `async` functions.
324329
///
325330
/// [`Future`]: crate::future::Future
326331
/// [output]: crate::future::Future::Output
332+
/// [`JoinHandle::join()`]: super::JoinHandle::join()
327333
#[unstable(feature = "thread_join_future", issue = "none")]
328334
pub fn into_join_future(self) -> super::JoinFuture<'scope, T> {
329335
// There is no `ScopedJoinFuture` because the only difference between `JoinHandle`

0 commit comments

Comments
 (0)