Skip to content

Commit 4d4870f

Browse files
authored
task: doc that task drops before JoinHandle completion (#7825)
1 parent fdb1509 commit 4d4870f

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

tokio/src/runtime/task/join.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::runtime::task::{Header, RawTask};
1+
use crate::runtime::task::{AbortHandle, Header, RawTask};
22

33
use std::fmt;
44
use std::future::Future;
@@ -22,6 +22,10 @@ cfg_rt! {
2222
/// This `struct` is created by the [`task::spawn`] and [`task::spawn_blocking`]
2323
/// functions.
2424
///
25+
/// It is guaranteed that the destructor of the spawned task has finished
26+
/// before task completion is observed via `JoinHandle` `await`,
27+
/// [`JoinHandle::is_finished`] or [`AbortHandle::is_finished`].
28+
///
2529
/// # Cancel safety
2630
///
2731
/// The `&mut JoinHandle<T>` type is cancel safe. If it is used as the event
@@ -300,9 +304,9 @@ impl<T> JoinHandle<T> {
300304
/// ```
301305
/// [cancelled]: method@super::error::JoinError::is_cancelled
302306
#[must_use = "abort handles do nothing unless `.abort` is called"]
303-
pub fn abort_handle(&self) -> super::AbortHandle {
307+
pub fn abort_handle(&self) -> AbortHandle {
304308
self.raw.ref_inc();
305-
super::AbortHandle::new(self.raw)
309+
AbortHandle::new(self.raw)
306310
}
307311

308312
/// Returns a [task ID] that uniquely identifies this task relative to other

0 commit comments

Comments
 (0)