task: add cancel safety docs to JoinHandle (#4901)

This commit is contained in:
Alice Ryhl
2022-08-11 11:17:03 +00:00
committed by GitHub
parent 53e127205b
commit bdbb0ece10
+9
View File
@@ -20,6 +20,15 @@ cfg_rt! {
/// This `struct` is created by the [`task::spawn`] and [`task::spawn_blocking`]
/// functions.
///
/// # Cancel safety
///
/// The `&mut JoinHandle<T>` type is cancel safe. If it is used as the event
/// in a `tokio::select!` statement and some other branch completes first,
/// then it is guaranteed that the output of the task is not lost.
///
/// If a `JoinHandle` is dropped, then the task continues running in the
/// background and its return value is lost.
///
/// # Examples
///
/// Creation from [`task::spawn`]: