Replace deprecated compare_and_swap with compare_exchange#617
Replace deprecated compare_and_swap with compare_exchange#617bors[bot] merged 1 commit intocrossbeam-rs:masterfrom
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.
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.
- 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.
- 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
| 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.
- 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 <te316e89@gmail.com>
compare_and_swapis deprecated in 1.50. (rust-lang/rust#79261)This patch replaces the uses of
compare_and_swapwithcompare_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