Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions tokio/src/runtime/task/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading