From 640d7ae06d2d0f205bf3920d26fda730de5ff6aa Mon Sep 17 00:00:00 2001 From: XMH <970252187@qq.com> Date: Wed, 10 Jun 2026 14:56:00 +0800 Subject: [PATCH 1/9] Update task.rs --- library/alloc/src/task.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/library/alloc/src/task.rs b/library/alloc/src/task.rs index bc668f78bf740..45c22b845799d 100644 --- a/library/alloc/src/task.rs +++ b/library/alloc/src/task.rs @@ -37,6 +37,10 @@ use crate::sync::Arc; /// link ../../std/task/struct.Waker.html#impl-From%3CArc%3CW,+Global%3E%3E-for-Waker /// without getting a link-checking error in CI. --> /// +/// # Memory Ordering +/// +/// To avoid missed wakeups, all runtimes must adhere to the requirement described for [`Waker::wake`]. +/// /// # Examples /// /// A basic `block_on` function that takes a future and runs it to completion on From 4671f48aa62496dfbd6c017dd289f6a59447b2a9 Mon Sep 17 00:00:00 2001 From: XMH <970252187@qq.com> Date: Wed, 10 Jun 2026 15:02:29 +0800 Subject: [PATCH 2/9] Update wake.rs --- library/core/src/task/wake.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/library/core/src/task/wake.rs b/library/core/src/task/wake.rs index 14f0980ff6045..0d50f9151e181 100644 --- a/library/core/src/task/wake.rs +++ b/library/core/src/task/wake.rs @@ -432,6 +432,13 @@ impl Waker { /// executor’s choice which task to run and the executor may choose to run the /// current task again. /// + /// To avoid missed wakeups, runtimes must ensure that for any call to `wake`, + /// there is a subsequent call to `poll` such that the `wake()` return _happens-before_ + /// the beginning of the invocation of `poll`. + /// In particular, this means that if a task self-wakes (invokes `wake` on itself during `poll`), + /// then the `poll` must be invoked again because the call to `wake` _happens-after_ the beginning + /// of the current invocation of `poll`. + /// /// [`poll()`]: crate::future::Future::poll #[inline] #[stable(feature = "futures_api", since = "1.36.0")] From 452882786afde92ac75b87f6be05b83b2fe8f3be Mon Sep 17 00:00:00 2001 From: XMH <970252187@qq.com> Date: Wed, 10 Jun 2026 15:41:12 +0800 Subject: [PATCH 3/9] Update wake.rs --- library/core/src/task/wake.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/core/src/task/wake.rs b/library/core/src/task/wake.rs index 0d50f9151e181..c184225778f9d 100644 --- a/library/core/src/task/wake.rs +++ b/library/core/src/task/wake.rs @@ -433,7 +433,7 @@ impl Waker { /// current task again. /// /// To avoid missed wakeups, runtimes must ensure that for any call to `wake`, - /// there is a subsequent call to `poll` such that the `wake()` return _happens-before_ + /// there is a subsequent call to `poll` such that the `wake()` _happens-before_ /// the beginning of the invocation of `poll`. /// In particular, this means that if a task self-wakes (invokes `wake` on itself during `poll`), /// then the `poll` must be invoked again because the call to `wake` _happens-after_ the beginning From 61aa16370b53d07c397812040210aede961ef34d Mon Sep 17 00:00:00 2001 From: XMH <970252187@qq.com> Date: Wed, 10 Jun 2026 16:10:30 +0800 Subject: [PATCH 4/9] Update library/core/src/task/wake.rs Co-authored-by: Alice Ryhl --- library/core/src/task/wake.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/core/src/task/wake.rs b/library/core/src/task/wake.rs index c184225778f9d..732a1855989ce 100644 --- a/library/core/src/task/wake.rs +++ b/library/core/src/task/wake.rs @@ -433,7 +433,7 @@ impl Waker { /// current task again. /// /// To avoid missed wakeups, runtimes must ensure that for any call to `wake`, - /// there is a subsequent call to `poll` such that the `wake()` _happens-before_ + /// there is a subsequent call to `poll` such that the call to `wake()` _happens-before_ /// the beginning of the invocation of `poll`. /// In particular, this means that if a task self-wakes (invokes `wake` on itself during `poll`), /// then the `poll` must be invoked again because the call to `wake` _happens-after_ the beginning From c5c5e814c6933a1d4a71332f6de68ba1e30c42d7 Mon Sep 17 00:00:00 2001 From: XMH <970252187@qq.com> Date: Wed, 10 Jun 2026 16:20:09 +0800 Subject: [PATCH 5/9] Update wake.rs --- library/core/src/task/wake.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/core/src/task/wake.rs b/library/core/src/task/wake.rs index 732a1855989ce..1428762db6234 100644 --- a/library/core/src/task/wake.rs +++ b/library/core/src/task/wake.rs @@ -434,7 +434,7 @@ impl Waker { /// /// To avoid missed wakeups, runtimes must ensure that for any call to `wake`, /// there is a subsequent call to `poll` such that the call to `wake()` _happens-before_ - /// the beginning of the invocation of `poll`. + /// the beginning of the invocation of `poll`. /// In particular, this means that if a task self-wakes (invokes `wake` on itself during `poll`), /// then the `poll` must be invoked again because the call to `wake` _happens-after_ the beginning /// of the current invocation of `poll`. From e65db4278bd9612d4145741dd9657ddcbea942cd Mon Sep 17 00:00:00 2001 From: XMH <970252187@qq.com> Date: Wed, 10 Jun 2026 17:51:02 +0800 Subject: [PATCH 6/9] Update library/core/src/task/wake.rs Co-authored-by: Alice Ryhl --- library/core/src/task/wake.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/library/core/src/task/wake.rs b/library/core/src/task/wake.rs index 1428762db6234..89c39e8b7836a 100644 --- a/library/core/src/task/wake.rs +++ b/library/core/src/task/wake.rs @@ -432,12 +432,13 @@ impl Waker { /// executor’s choice which task to run and the executor may choose to run the /// current task again. /// - /// To avoid missed wakeups, runtimes must ensure that for any call to `wake`, - /// there is a subsequent call to `poll` such that the call to `wake()` _happens-before_ - /// the beginning of the invocation of `poll`. - /// In particular, this means that if a task self-wakes (invokes `wake` on itself during `poll`), - /// then the `poll` must be invoked again because the call to `wake` _happens-after_ the beginning - /// of the current invocation of `poll`. + /// To avoid missed wakeups, runtimes must ensure that for any call to + /// `wake`, there is a subsequent call to `poll` such that the call to + /// `wake()` _happens-before_ the beginning of the invocation of `poll`. In + /// particular, this means that if a task self-wakes (invokes `wake` on + /// itself during `poll`), then the `poll` must be invoked again because the + /// call to `wake` _happens-after_ the beginning of the current invocation + /// of `poll`. /// /// [`poll()`]: crate::future::Future::poll #[inline] From 16ccf8e66ca9ef666f7ba76f863cc7c2a6f24ec2 Mon Sep 17 00:00:00 2001 From: XMH <970252187@qq.com> Date: Thu, 11 Jun 2026 09:46:23 +0800 Subject: [PATCH 7/9] Update library/alloc/src/task.rs Co-authored-by: Kevin Reid --- library/alloc/src/task.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/alloc/src/task.rs b/library/alloc/src/task.rs index 45c22b845799d..0e36c91f466fd 100644 --- a/library/alloc/src/task.rs +++ b/library/alloc/src/task.rs @@ -39,7 +39,7 @@ use crate::sync::Arc; /// /// # Memory Ordering /// -/// To avoid missed wakeups, all runtimes must adhere to the requirement described for [`Waker::wake`]. +/// To avoid missed wakeups, all executors must adhere to the requirement described for [`Waker::wake`]. /// /// # Examples /// From a0ecf25ca93d432786c0f5428eed76dd549ac8c8 Mon Sep 17 00:00:00 2001 From: XMH <970252187@qq.com> Date: Thu, 11 Jun 2026 09:46:38 +0800 Subject: [PATCH 8/9] Update library/core/src/task/wake.rs Co-authored-by: Kevin Reid --- library/core/src/task/wake.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/core/src/task/wake.rs b/library/core/src/task/wake.rs index 89c39e8b7836a..c3f7672a61a37 100644 --- a/library/core/src/task/wake.rs +++ b/library/core/src/task/wake.rs @@ -432,7 +432,7 @@ impl Waker { /// executor’s choice which task to run and the executor may choose to run the /// current task again. /// - /// To avoid missed wakeups, runtimes must ensure that for any call to + /// To avoid missed wakeups, executors must ensure that for any call to /// `wake`, there is a subsequent call to `poll` such that the call to /// `wake()` _happens-before_ the beginning of the invocation of `poll`. In /// particular, this means that if a task self-wakes (invokes `wake` on From 0954d4c64447fcce89c388af8d13e473db43b383 Mon Sep 17 00:00:00 2001 From: XMH <970252187@qq.com> Date: Fri, 12 Jun 2026 13:52:01 +0800 Subject: [PATCH 9/9] Update wake.rs --- library/core/src/task/wake.rs | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/library/core/src/task/wake.rs b/library/core/src/task/wake.rs index c3f7672a61a37..bdf6c59a80b80 100644 --- a/library/core/src/task/wake.rs +++ b/library/core/src/task/wake.rs @@ -418,28 +418,21 @@ unsafe impl Sync for Waker {} impl Waker { /// Wakes up the task associated with this `Waker`. /// - /// As long as the executor keeps running and the task is not finished, it is - /// guaranteed that each invocation of [`wake()`](Self::wake) (or + /// As long as the executor keeps running and the task is not finished, + /// it is guaranteed that each invocation of [`wake()`](Self::wake) (or /// [`wake_by_ref()`](Self::wake_by_ref)) will be followed by at least one - /// [`poll()`] of the task to which this `Waker` belongs. This makes - /// it possible to temporarily yield to other tasks while running potentially - /// unbounded processing loops. + /// [`poll()`] of the task to which this `Waker` belongs, and the call to + /// [`wake()`](Self::wake) (or [`wake_by_ref()`](Self::wake_by_ref)) _happens-before_ + /// the beginning of the invocation of [`poll()`]. This makes it possible to temporarily + /// yield to other tasks while running potentially unbounded processing loops. /// /// Note that the above implies that multiple wake-ups may be coalesced into a - /// single [`poll()`] invocation by the runtime. + /// single [`poll()`] invocation by the executor. /// /// Also note that yielding to competing tasks is not guaranteed: it is the /// executor’s choice which task to run and the executor may choose to run the /// current task again. /// - /// To avoid missed wakeups, executors must ensure that for any call to - /// `wake`, there is a subsequent call to `poll` such that the call to - /// `wake()` _happens-before_ the beginning of the invocation of `poll`. In - /// particular, this means that if a task self-wakes (invokes `wake` on - /// itself during `poll`), then the `poll` must be invoked again because the - /// call to `wake` _happens-after_ the beginning of the current invocation - /// of `poll`. - /// /// [`poll()`]: crate::future::Future::poll #[inline] #[stable(feature = "futures_api", since = "1.36.0")]