For example, the compare exchange for OnceNonZeroUsize uses AcqRel for the success case:
|
self.inner.compare_exchange(0, val, Ordering::AcqRel, Ordering::Acquire); |
The Acquire portion of the AcqRel here is for the load of 0, however there is no Release store of 0 so this will not synchronize with anything. Note that the construction of OnceNonZeroUsize still has a happens-before relationship to this since we have an &self reference. Thus, I think a Release ordering is sufficient here for the desired synchronization to be achieved (including taking this documentation into account):
self.inner.compare_exchange(0, val, Ordering::Release, Ordering::Acquire);
I believe this applies to all uses of compare_exchange in this module.
(happy to make a PR if this looks reasonable)
For example, the compare exchange for
OnceNonZeroUsizeusesAcqRelfor the success case:once_cell/src/race.rs
Line 100 in d706539
The
Acquireportion of theAcqRelhere is for the load of0, however there is noReleasestore of0so this will not synchronize with anything. Note that the construction ofOnceNonZeroUsizestill has a happens-before relationship to this since we have an&selfreference. Thus, I think aReleaseordering is sufficient here for the desired synchronization to be achieved (including taking this documentation into account):I believe this applies to all uses of
compare_exchangein this module.(happy to make a PR if this looks reasonable)