mpsc: use spin_loop_hint instead of yield_now (#4115)

This commit is contained in:
Alice Ryhl
2021-09-18 09:27:25 +02:00
committed by GitHub
parent ddd33f2b05
commit f1b89675eb
2 changed files with 14 additions and 7 deletions
+14 -1
View File
@@ -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,
};
}
-6
View File
@@ -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();
}
}
}