-
Notifications
You must be signed in to change notification settings - Fork 424
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
Should we keep compareExchange and compareExchangeStrong? #13837
Comments
compareExchange stong should be the "default" since compareExchangeWeak is an optimization. I think deprecating compareExchangeStrong is reasonable. |
I feel inclined to keep compareExchangeStrong() so that someone coming from C++ will find the familiar name easily and to keep compareExchange() for convenience. I might also consider adding a |
I think my preference is to just have Adding Plus it wouldn't be a breaking change to add |
FWIW Rust went with |
Suppose we did that. Suppose such a user coming from C++ is reading some Chapel code. That Chapel code might use compareExchange (which we are supposing exists only for convenience). In this case there is no benefit to that user to keeping compareExchangeStrong, right? At that point isn't it just a matter of writing something they can find with grep/search in the documentation? |
Vote for |
Vote for |
Not enough to fight against this tide. I still find the notion of a param arg on compareExchange() intriguing, but not enough to fight for that either (and it can always be added later if someone wants to argue for it). |
Ok, thanks Since |
We implement
compareExchange()
, which is just an alias ofcompareExchangeStrong()
. It seems odd to me to have both, and I propose we deprecate one of them. I don't have a strong preference on which one we deprecate. C/C++ havecompare_exchange_weak()
andcompare_exchange_strong()
. Rust went withcompare_exchange_weak()
andcompare_exchange()
For some additional context
compare_exchange_weak()
can spuriously fail, and is intended to be used in situations where you'd be looping anyways as it can offer better performance on some platforms. https://stackoverflow.com/questions/25199838/understanding-stdatomiccompare-exchange-weak-in-c11 has a pretty good explanation of weak vs. strong CAS.The text was updated successfully, but these errors were encountered: