Stabilize spin_loop_hint
This commit is contained in:
parent
b1409af73d
commit
6ceb5f4bec
2 changed files with 6 additions and 7 deletions
|
|
@ -1,4 +1,4 @@
|
|||
# `hint_core_should_pause`
|
||||
# `spin_loop_hint`
|
||||
|
||||
The tracking issue for this feature is: [#41196]
|
||||
|
||||
|
|
@ -23,7 +23,7 @@ fn spin_loop(value: &AtomicBool) {
|
|||
These programs can be improved in performance like so:
|
||||
|
||||
```rust,no_run
|
||||
#![feature(hint_core_should_pause)]
|
||||
#![feature(spin_loop_hint)]
|
||||
use std::sync::atomic;
|
||||
use std::sync::atomic::{AtomicBool,Ordering};
|
||||
|
||||
|
|
@ -32,10 +32,10 @@ fn spin_loop(value: &AtomicBool) {
|
|||
if value.load(Ordering::Acquire) {
|
||||
break;
|
||||
}
|
||||
atomic::hint_core_should_pause();
|
||||
atomic::spin_loop_hint();
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Further improvements could combine `hint_core_should_pause` with
|
||||
Further improvements could combine `spin_loop_hint` with
|
||||
exponential backoff or `std::thread::yield_now`.
|
||||
|
|
@ -103,9 +103,8 @@ use fmt;
|
|||
///
|
||||
/// On some platforms this function may not do anything at all.
|
||||
#[inline]
|
||||
#[unstable(feature = "hint_core_should_pause", issue = "41196")]
|
||||
pub fn hint_core_should_pause()
|
||||
{
|
||||
#[stable(feature = "spin_loop_hint", since = "1.23.0")]
|
||||
pub fn spin_loop_hint() {
|
||||
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
||||
unsafe {
|
||||
asm!("pause" ::: "memory" : "volatile");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue