-
Notifications
You must be signed in to change notification settings - Fork 470
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
Add Atomic::compare_exchange(_weak) and deprecate Atomic::compare_and_set(_weak) #628
Conversation
I don't know why this method was originally called compare-and-set, but Wikipedia says a variant of compare-and-swap that returns a boolean indicating whether a substitution was performed is often called compare-and-set. https://en.wikipedia.org/wiki/Compare-and-swap
As this method actually returns a value rather than a boolean, I think it's okay to call it |
std's compare_exchange receives two orderings: one for success and the other for fail cases. But this PR's compare_exchange receives only one that can be rendered into two. Do you think we need to match them? |
Uh, both methods ( crossbeam/crossbeam-epoch/src/atomic.rs Lines 456 to 465 in 4f0fcd5
crossbeam/crossbeam-epoch/src/atomic.rs Lines 531 to 540 in 4f0fcd5
|
Updated the PR description to explain the changes in more detail. |
bors r+ |
Build succeeded: |
659: Prepare for the next release r=taiki-e a=taiki-e It's been over two months since the previous release. There are some improvements and deprecations in the master branch, and it would be nice to release them. Also, there is no breaking change that needs a major version bump. Changes: - crossbeam-epoch 0.9.1 -> 0.9.2 - Add `Atomic::compare_exchange` and `Atomic::compare_exchange_weak`. (#628) - Deprecate `Atomic::compare_and_set` and `Atomic::compare_and_set_weak`. (#628) - Make `const_fn` dependency optional. (#611) - Add unstable support for `loom`. (#487) - crossbeam-utils 0.8.1 -> 0.8.2 - Deprecate `AtomicCell::compare_and_swap`. (#619) - Add `Parker::park_deadline`. (#563) - Improve implementation of `CachePadded`. (#636) - Add unstable support for `loom`. (#487) Co-authored-by: Taiki Endo <te316e89@gmail.com>
Instead of changing the argument of
Atomic::compare_and_set(_weak)
, add new methodsAtomic::compare_exchange(_weak)
that always use two orderings.This PR adds:
Atomic::compare_exchange
Unlike
compare_and_set
, this always receive two orderings.Atomic::compare_exchange_weak
Unlike
compare_and_set_weak
, this always receive two orderings.CompareExchangeError
(error returned byAtomic::compare_exchange(_weak)
)The definition is the same as
CompareAndSetError
, just renamedCompareExchangeError
.This PR deprecates:
Atomic::compare_and_set
Atomic::compare_and_set_weak
CompareAndSetError
(error returned byAtomic::compare_and_set(_weak)
)This is now a type alias of
CompareExchangeError
.CompareAndSetOrdering
Closes #621