Skip to content

Commit 188f976

Browse files
authored
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.
1 parent 568a314 commit 188f976

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/lib.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ impl State {
543543
fn notify(&self) {
544544
if self
545545
.notified
546-
.compare_exchange(false, true, Ordering::SeqCst, Ordering::SeqCst)
546+
.compare_exchange(false, true, Ordering::AcqRel, Ordering::Acquire)
547547
.is_ok()
548548
{
549549
let waker = self.sleepers.lock().unwrap().notify();
@@ -672,7 +672,7 @@ impl Ticker<'_> {
672672

673673
self.state
674674
.notified
675-
.swap(sleepers.is_notified(), Ordering::SeqCst);
675+
.store(sleepers.is_notified(), Ordering::Release);
676676

677677
true
678678
}
@@ -685,7 +685,7 @@ impl Ticker<'_> {
685685

686686
self.state
687687
.notified
688-
.swap(sleepers.is_notified(), Ordering::SeqCst);
688+
.store(sleepers.is_notified(), Ordering::Release);
689689
}
690690
self.sleeping = 0;
691691
}
@@ -733,7 +733,7 @@ impl Drop for Ticker<'_> {
733733

734734
self.state
735735
.notified
736-
.swap(sleepers.is_notified(), Ordering::SeqCst);
736+
.store(sleepers.is_notified(), Ordering::Release);
737737

738738
// If this ticker was notified, then notify another ticker.
739739
if notified {

0 commit comments

Comments
 (0)