From 5cef6eba7bbb0c35726e36c2b8d71351c8000be4 Mon Sep 17 00:00:00 2001 From: Sigurd Date: Wed, 19 Apr 2023 17:42:32 +0200 Subject: [PATCH] sync: improve CancellationToken doc on child tokens (#5632) --- tokio-util/src/sync/cancellation_token.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tokio-util/src/sync/cancellation_token.rs b/tokio-util/src/sync/cancellation_token.rs index c44be6986..2c4e0250d 100644 --- a/tokio-util/src/sync/cancellation_token.rs +++ b/tokio-util/src/sync/cancellation_token.rs @@ -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.