mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-29 00:00:11 +02:00
runtime: use release in wake_by_ref() even if already woken (#7622)
(cherry picked from commit 67869be3d7)
This commit is contained in:
@@ -252,9 +252,15 @@ impl State {
|
|||||||
/// Transitions the state to `NOTIFIED`.
|
/// Transitions the state to `NOTIFIED`.
|
||||||
pub(super) fn transition_to_notified_by_ref(&self) -> TransitionToNotifiedByRef {
|
pub(super) fn transition_to_notified_by_ref(&self) -> TransitionToNotifiedByRef {
|
||||||
self.fetch_update_action(|mut snapshot| {
|
self.fetch_update_action(|mut snapshot| {
|
||||||
if snapshot.is_complete() || snapshot.is_notified() {
|
if snapshot.is_complete() {
|
||||||
// There is nothing to do in this case.
|
// The complete state is final
|
||||||
(TransitionToNotifiedByRef::DoNothing, None)
|
(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() {
|
} else if snapshot.is_running() {
|
||||||
// If the task is running, we mark it as notified, but we should
|
// If the task is running, we mark it as notified, but we should
|
||||||
// not submit as the thread currently running the future is
|
// not submit as the thread currently running the future is
|
||||||
|
|||||||
Reference in New Issue
Block a user