m: Weaken the atomic orderings for notification

The atomic orderings on State::notified might be too strong, as it's primarily
being used as a deterrent against waking up too many threads. This PR weakens
their sequentially consistent operations to Acquire/Release.
This commit is contained in:
James Liu 2024-02-17 12:20:57 -08:00 committed by GitHub
parent 568a314ad9
commit 188f976dc3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 4 deletions

View File

@ -543,7 +543,7 @@ impl State {
fn notify(&self) {
if self
.notified
.compare_exchange(false, true, Ordering::SeqCst, Ordering::SeqCst)
.compare_exchange(false, true, Ordering::AcqRel, Ordering::Acquire)
.is_ok()
{
let waker = self.sleepers.lock().unwrap().notify();
@ -672,7 +672,7 @@ impl Ticker<'_> {
self.state
.notified
.swap(sleepers.is_notified(), Ordering::SeqCst);
.store(sleepers.is_notified(), Ordering::Release);
true
}
@ -685,7 +685,7 @@ impl Ticker<'_> {
self.state
.notified
.swap(sleepers.is_notified(), Ordering::SeqCst);
.store(sleepers.is_notified(), Ordering::Release);
}
self.sleeping = 0;
}
@ -733,7 +733,7 @@ impl Drop for Ticker<'_> {
self.state
.notified
.swap(sleepers.is_notified(), Ordering::SeqCst);
.store(sleepers.is_notified(), Ordering::Release);
// If this ticker was notified, then notify another ticker.
if notified {