Skip to content

Commit

Permalink
Merge #647
Browse files Browse the repository at this point in the history
647: Ignore deprecated warnings on spin_loop_hint r=taiki-e a=taiki-e

`spin_loop_hint` is deprecated in 1.51. (rust-lang/rust#80966)

However, the alternative (`hint::spin_loop`) requires Rust 1.49+, so ignore deprecated warnings for now.

Co-authored-by: Taiki Endo <[email protected]>
  • Loading branch information
bors[bot] and taiki-e authored Jan 15, 2021
2 parents 99c66ec + 7e54f8b commit 90cd7dc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
9 changes: 9 additions & 0 deletions crossbeam-utils/src/backoff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ impl Backoff {
#[inline]
pub fn spin(&self) {
for _ in 0..1 << self.step.get().min(SPIN_LIMIT) {
// TODO(taiki-e): once we bump the minimum required Rust version to 1.49+,
// use [`core::hint::spin_loop`] instead.
#[allow(deprecated)]
atomic::spin_loop_hint();
}

Expand Down Expand Up @@ -205,11 +208,17 @@ impl Backoff {
pub fn snooze(&self) {
if self.step.get() <= SPIN_LIMIT {
for _ in 0..1 << self.step.get() {
// TODO(taiki-e): once we bump the minimum required Rust version to 1.49+,
// use [`core::hint::spin_loop`] instead.
#[allow(deprecated)]
atomic::spin_loop_hint();
}
} else {
#[cfg(not(feature = "std"))]
for _ in 0..1 << self.step.get() {
// TODO(taiki-e): once we bump the minimum required Rust version to 1.49+,
// use [`core::hint::spin_loop`] instead.
#[allow(deprecated)]
atomic::spin_loop_hint();
}

Expand Down
3 changes: 3 additions & 0 deletions crossbeam-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ mod primitive {
pub(crate) mod sync {
pub(crate) mod atomic {
pub(crate) use core::sync::atomic::compiler_fence;
// TODO(taiki-e): once we bump the minimum required Rust version to 1.49+,
// use [`core::hint::spin_loop`] instead.
#[allow(deprecated)]
pub(crate) use core::sync::atomic::spin_loop_hint;
pub(crate) use core::sync::atomic::{AtomicBool, AtomicIsize, AtomicUsize};
#[cfg(has_atomic_u16)]
Expand Down

0 comments on commit 90cd7dc

Please sign in to comment.