-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Change compare_exchange to return a Result<T, T> #32244
Conversation
d7e8302
to
acb9256
Compare
Thanks @Amanieu! From a technical perspective the change looks good to me, just a question of APIs now! I'm tagging this with So I originally thought that this may make the classical "compare exchange loop" a little less ergnomic as getting the value out would require current: loop {
let new = f(current);
let old = foo.compare_exchange(current, new, ord1, ord2);
if old == current {
break
}
current = old;
} new: loop {
let new = f(current);
match foo.compare_exchange(current, new, ord1, ord2) {
Ok(..) => break,
Err(old) => current = old,
}
} I gotta say using To get a handle on the ergonomics though it may be worthwhile to port a project like crossbeam to using this API instead of the old one (just as a smoke test) |
The libs team discussed this during triage yesterday and the conclusion was that this seems like a good change to have! It was brought up though that we may not want to change the feature names as that's kinda unnecessary breakage, would you be ok changing back? |
cb3e048
to
2964f18
Compare
Done |
@bors: r+ 2964f1873e54b42cc3994ba8882d2486305c32c3 |
⌛ Testing commit 2964f18 with merge dedfe4a... |
💔 Test failed - auto-mac-64-opt |
2964f18
to
928d8cd
Compare
Fixed |
928d8cd
to
18222c0
Compare
@alexcrichton This will have to wait until #32080 is merged, btw. |
☔ The latest upstream changes (presumably #32080) made this pull request unmergeable. Please resolve the merge conflicts. |
4187714
to
6f0a130
Compare
I think this should be fixed now |
@bors: r+ 6f0a1307741e7d1d297aeffd2ec15eb905e1d487 |
⌛ Testing commit 6f0a130 with merge 424af07... |
@bors: retry force clean |
⌛ Testing commit 6f0a130 with merge 8021fa5... |
💔 Test failed - auto-mac-64-nopt-t |
6f0a130
to
421fed1
Compare
Fixed. Note that it seems atomic intrinsics currently don't work on non-integer types, this should be properly fixed at some point... |
⌛ Testing commit 421fed1 with merge 58ca226... |
💔 Test failed - auto-win-msvc-64-opt-rustbuild |
@bors: retry On Sat, Mar 19, 2016 at 12:11 PM, bors [email protected] wrote:
|
Change compare_exchange to return a Result<T, T> As per the discussion in #31767 I also changed the feature name from `extended_compare_and_swap` to `compare_exchange`. r? @alexcrichton
As per the discussion in #31767
I also changed the feature name from
extended_compare_and_swap
tocompare_exchange
.r? @alexcrichton