sync: improve CancellationToken doc on child tokens (#5632)

This commit is contained in:
Sigurd 2023-04-19 17:42:32 +02:00 committed by GitHub
parent db543639e1
commit 5cef6eba7b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -97,6 +97,8 @@ impl core::fmt::Debug for CancellationToken {
}
impl Clone for CancellationToken {
/// Creates a clone of the `CancellationToken` which will get cancelled
/// whenever the current token gets cancelled, and vice versa.
fn clone(&self) -> Self {
tree_node::increase_handle_refcount(&self.inner);
CancellationToken {
@ -126,7 +128,8 @@ impl CancellationToken {
}
/// Creates a `CancellationToken` which will get cancelled whenever the
/// current token gets cancelled.
/// current token gets cancelled. Unlike a cloned `CancellationToken`,
/// cancelling a child token does not cancel the parent token.
///
/// If the current token is already cancelled, the child token will get
/// returned in cancelled state.