Skip to content

Commit efd8c46

Browse files
committed
Move note about foreign-unwind guarantee to 'thread::spawn', and refer to them in 'JoinHandle::join' note
1 parent 268b29e commit efd8c46

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

library/std/src/thread/mod.rs

+20-8
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,19 @@ impl Builder {
665665
/// println!("{result}");
666666
/// ```
667667
///
668+
/// # Notes
669+
///
670+
/// This function has the same minimal guarantee regarding "foreign" unwinding operations (e.g.
671+
/// an exception thrown from C++ code, or a `panic!` in Rust code compiled or linked with a
672+
/// different runtime) as [`catch_unwind`]; namely, if the thread created with `thread::spawn`
673+
/// unwinds all the way to the root with such an exception, one of two behaviors are possible,
674+
/// and it is unspecified which will occur:
675+
///
676+
/// * The process aborts.
677+
/// * The process does not abort, and [`join`] will return a `Result::Err`
678+
/// containing an opaque type.
679+
///
680+
/// [`catch_unwind`]: ../../std/panic/fn.catch_unwind.html
668681
/// [`channels`]: crate::sync::mpsc
669682
/// [`join`]: JoinHandle::join
670683
/// [`Err`]: crate::result::Result::Err
@@ -1762,16 +1775,15 @@ impl<T> JoinHandle<T> {
17621775
///
17631776
/// # Notes
17641777
///
1765-
/// This function has the same minimal guarantee regarding "foreign" unwinding operations (e.g.
1766-
/// an exception thrown from C++ code, or a `panic!` in Rust code compiled or linked with a
1767-
/// different runtime) as [`catch_unwind`]; namely, if the thread created with `thread::spawn`
1768-
/// unwinds all the way to the root with such an exception, this function will have one of two
1769-
/// behaviors, and it is unspecified which will occur:
1770-
///
1771-
/// * The process aborts.
1772-
/// * The function returns a `Result::Err` containing an opaque type.
1778+
/// If a "foreign" unwinding operation (e.g. an exception thrown from C++
1779+
/// code, or a `panic!` in Rust code compiled or linked with a different
1780+
/// runtime) unwinds all the way to the thread root, the process may be
1781+
/// aborted; see the Notes on [`thread::spawn`]. If the process is not
1782+
/// aborted, this function will return a `Result::Err` containing an opaque
1783+
/// type.
17731784
///
17741785
/// [`catch_unwind`]: ../../std/panic/fn.catch_unwind.html
1786+
/// [`thread::spawn`]: spawn
17751787
#[stable(feature = "rust1", since = "1.0.0")]
17761788
pub fn join(self) -> Result<T> {
17771789
self.0.join()

0 commit comments

Comments
 (0)