mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-26 00:00:16 +02:00
mpsc: use spin_loop_hint instead of yield_now (#4115)
This commit is contained in:
@@ -93,4 +93,17 @@ pub(crate) mod sys {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) use std::thread;
|
||||
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();
|
||||
}
|
||||
|
||||
#[allow(unused_imports)]
|
||||
pub(crate) use std::thread::{
|
||||
current, panicking, park, park_timeout, sleep, spawn, Builder, JoinHandle, LocalKey,
|
||||
Result, Thread, ThreadId,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -343,13 +343,7 @@ impl<T> Block<T> {
|
||||
Err(curr) => curr,
|
||||
};
|
||||
|
||||
#[cfg(all(test, loom))]
|
||||
crate::loom::thread::yield_now();
|
||||
|
||||
// TODO: once we bump MSRV to 1.49+, use `hint::spin_loop` instead.
|
||||
#[cfg(not(all(test, loom)))]
|
||||
#[allow(deprecated)]
|
||||
std::sync::atomic::spin_loop_hint();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user