runtime: use release in wake_by_ref() even if already woken (#7622)

(cherry picked from commit 67869be3d7)
This commit is contained in:
Adam Ning
2025-10-14 22:13:54 +08:00
committed by Qi
parent 4fee6e3500
commit b9feac8d68
+8 -2
View File
@@ -252,9 +252,15 @@ impl State {
/// Transitions the state to `NOTIFIED`.
pub(super) fn transition_to_notified_by_ref(&self) -> TransitionToNotifiedByRef {
self.fetch_update_action(|mut snapshot| {
if snapshot.is_complete() || snapshot.is_notified() {
// There is nothing to do in this case.
if snapshot.is_complete() {
// The complete state is final
(TransitionToNotifiedByRef::DoNothing, None)
} else if snapshot.is_notified() {
// Even hough we have nothing to do in this branch,
// wake_by_ref() should synchronize-with the task starting execution,
// therefore we must use an Release store (with the same value),
// to pair with the Acquire in transition_to_running.
(TransitionToNotifiedByRef::DoNothing, Some(snapshot))
} else if snapshot.is_running() {
// If the task is running, we mark it as notified, but we should
// not submit as the thread currently running the future is