-
Notifications
You must be signed in to change notification settings - Fork 472
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
Replace deprecated compare_and_swap with compare_exchange #617
Conversation
pub fn compare_and_swap(&self, current: Epoch, new: Epoch, ord: Ordering) -> Epoch { | ||
let data = self.data.compare_and_swap(current.data, new.data, ord); | ||
Epoch { data } | ||
pub fn compare_exchange( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: This is marked as pub
, but this is a function used only within the crate and not exposed, so this change does not break the public API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- By "exposed", you mean it's not part of the public API?
- Even if it is public, I vote for chaging like you suggested. We're before 1.0 :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- By "exposed", you mean it's not part of the public API?
Yes, this function and AtomicEpoch
that implements this function is not part of the public API: https://docs.rs/crossbeam-epoch/0.9.1/crossbeam_epoch/#structs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
bors r+
pub fn compare_and_swap(&self, current: Epoch, new: Epoch, ord: Ordering) -> Epoch { | ||
let data = self.data.compare_and_swap(current.data, new.data, ord); | ||
Epoch { data } | ||
pub fn compare_exchange( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- By "exposed", you mean it's not part of the public API?
- Even if it is public, I vote for chaging like you suggested. We're before 1.0 :)
Just one more thing: do you think it's also worth changing the APIs of |
Did you mean |
Build succeeded: |
637: Apply unreachable_pub lint r=jeehoonkang a=taiki-e `unreachable_pub` lint warns items that are marked as `pub` but are not actually included in the public API, and suggests using `pub(crate)` instead. `pub(crate)` is a bit more verbose than `pub`, but this should make it easier to review changes that make it difficult to tell if it will break API or not just by looking at the diff like #617 (comment). Especially, there are many such codes in crossbeam-channel and crossbeam-epoch. (Hopefully, after this patch, we can basically consider all items marked `pub` are public APIs, except for items that have been explicitly hidden from the public API by `#[doc(hidden)]`.) This lint is known to have some false positives, but the crossbeam doesn't seem to be affected. Co-authored-by: Taiki Endo <[email protected]>
compare_and_swap
is deprecated in 1.50. (rust-lang/rust#79261)This patch replaces the uses of
compare_and_swap
withcompare_exchange
.See also the document about
compare_and_swap
->compare_exchange(_weak)
migration: https://doc.rust-lang.org/nightly/core/sync/atomic/struct.AtomicUsize.html#migrating-to-compare_exchange-and-compare_exchange_weak