From ef5b6af7f6b641db7a1ed1f09534bc75943bf835 Mon Sep 17 00:00:00 2001 From: Luca Bruno Date: Mon, 4 Aug 2025 15:26:11 +0200 Subject: [PATCH] future: clarify the fairness of `FutureExt` for cancellation adapters (#7512) This fixes the docstrings on `FutureExt` so that the bias and fairness notes are correct and consistent in all cases. All cancellation-related wrappers are biased towards the completion of the inner future, but they do initially check if the token is already cancelled at construction time. --- tokio-util/src/future.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tokio-util/src/future.rs b/tokio-util/src/future.rs index ba4779908..408de66b9 100644 --- a/tokio-util/src/future.rs +++ b/tokio-util/src/future.rs @@ -59,14 +59,13 @@ pub trait FutureExt: Future { } /// Similar to [`CancellationToken::run_until_cancelled`], - /// but with the advantage that it is easier to write fluent call chains, - /// and biased towards waiting for [`CancellationToken`] to complete. + /// but with the advantage that it is easier to write fluent call chains. /// /// # Fairness /// /// Calling this on an already-cancelled token directly returns `None`. /// For all subsequent polls, in case of concurrent completion and - /// cancellation, this is biased towards the future completion. + /// cancellation, this is biased towards the `self` future completion. /// /// # Examples /// @@ -97,14 +96,13 @@ pub trait FutureExt: Future { } /// Similar to [`CancellationToken::run_until_cancelled_owned`], - /// but with the advantage that it is easier to write fluent call chains, - /// and biased towards waiting for [`CancellationToken`] to complete. + /// but with the advantage that it is easier to write fluent call chains. /// /// # Fairness /// /// Calling this on an already-cancelled token directly returns `None`. /// For all subsequent polls, in case of concurrent completion and - /// cancellation, this is biased towards the future completion. + /// cancellation, this is biased towards the `self` future completion. /// /// # Examples ///