diff --git a/tokio/src/loom/std/mod.rs b/tokio/src/loom/std/mod.rs index 8b6e8bc19d7..0c70bee74eb 100644 --- a/tokio/src/loom/std/mod.rs +++ b/tokio/src/loom/std/mod.rs @@ -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)] diff --git a/tokio/src/sync/task/atomic_waker.rs b/tokio/src/sync/task/atomic_waker.rs index e1330fb1050..13aba354488 100644 --- a/tokio/src/sync/task/atomic_waker.rs +++ b/tokio/src/sync/task/atomic_waker.rs @@ -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