Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

time: small implementation cleanups #6517

Merged
merged 11 commits into from
May 1, 2024
Merged
Next Next commit
time: use compare_exchange_weak in StateCell::mark_pending
`StateCell::mark_pending` already uses a loop to retry the
compare exchange operation if it fails.

The logic within the loop would handle a spurious failure
like any other failure, so `compare_exchange_weak` makes
the implementation more efficient for some platforms.
  • Loading branch information
paolobarbolini committed Apr 25, 2024
commit bda0d8f61b411b985140e98043cf153d2ee5a38b
2 changes: 1 addition & 1 deletion tokio/src/runtime/time/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ impl StateCell {
break Err(cur_state);
}

match self.state.compare_exchange(
match self.state.compare_exchange_weak(
cur_state,
STATE_PENDING_FIRE,
Ordering::AcqRel,
Expand Down