task: doc that task drops before JoinHandle completion (#7825)

This commit is contained in:
Stepan Koltsov
2026-01-03 13:41:03 +00:00
committed by GitHub
parent fdb150901a
commit 4d4870f291
+7 -3
View File
@@ -1,4 +1,4 @@
use crate::runtime::task::{Header, RawTask};
use crate::runtime::task::{AbortHandle, Header, RawTask};
use std::fmt;
use std::future::Future;
@@ -22,6 +22,10 @@ cfg_rt! {
/// This `struct` is created by the [`task::spawn`] and [`task::spawn_blocking`]
/// functions.
///
/// It is guaranteed that the destructor of the spawned task has finished
/// before task completion is observed via `JoinHandle` `await`,
/// [`JoinHandle::is_finished`] or [`AbortHandle::is_finished`].
///
/// # Cancel safety
///
/// The `&mut JoinHandle<T>` type is cancel safe. If it is used as the event
@@ -300,9 +304,9 @@ impl<T> JoinHandle<T> {
/// ```
/// [cancelled]: method@super::error::JoinError::is_cancelled
#[must_use = "abort handles do nothing unless `.abort` is called"]
pub fn abort_handle(&self) -> super::AbortHandle {
pub fn abort_handle(&self) -> AbortHandle {
self.raw.ref_inc();
super::AbortHandle::new(self.raw)
AbortHandle::new(self.raw)
}
/// Returns a [task ID] that uniquely identifies this task relative to other