replace spin_loop_hint with hint::spin_loop (#4491)

This commit is contained in:
Name1e5s
2022-02-12 11:47:04 -08:00
committed by GitHub
parent 62274b0710
commit 02141db1e1
2 changed files with 8 additions and 10 deletions
+5 -6
View File
@@ -25,6 +25,10 @@ pub(crate) mod future {
pub(crate) use crate::sync::AtomicWaker;
}
pub(crate) mod hint {
pub(crate) use std::hint::spin_loop;
}
pub(crate) mod rand {
use std::collections::hash_map::RandomState;
use std::hash::{BuildHasher, Hash, Hasher};
@@ -75,9 +79,6 @@ pub(crate) mod sync {
pub(crate) use crate::loom::std::atomic_usize::AtomicUsize;
pub(crate) use std::sync::atomic::{fence, AtomicBool, Ordering};
// TODO: once we bump MSRV to 1.49+, use `hint::spin_loop` instead.
#[allow(deprecated)]
pub(crate) use std::sync::atomic::spin_loop_hint;
}
}
@@ -96,9 +97,7 @@ pub(crate) mod sys {
pub(crate) mod thread {
#[inline]
pub(crate) fn yield_now() {
// TODO: once we bump MSRV to 1.49+, use `hint::spin_loop` instead.
#[allow(deprecated)]
std::sync::atomic::spin_loop_hint();
std::hint::spin_loop();
}
#[allow(unused_imports)]
+3 -4
View File
@@ -1,7 +1,8 @@
#![cfg_attr(any(loom, not(feature = "sync")), allow(dead_code, unreachable_pub))]
use crate::loom::cell::UnsafeCell;
use crate::loom::sync::atomic::{self, AtomicUsize};
use crate::loom::hint;
use crate::loom::sync::atomic::AtomicUsize;
use std::fmt;
use std::panic::{resume_unwind, AssertUnwindSafe, RefUnwindSafe, UnwindSafe};
@@ -281,9 +282,7 @@ impl AtomicWaker {
waker.wake();
// This is equivalent to a spin lock, so use a spin hint.
// TODO: once we bump MSRV to 1.49+, use `hint::spin_loop` instead.
#[allow(deprecated)]
atomic::spin_loop_hint();
hint::spin_loop();
}
state => {
// In this case, a concurrent thread is holding the