Skip to content

Commit 6ceb5f4

Browse files
author
Stjepan Glavina
committed
Stabilize spin_loop_hint
1 parent b1409af commit 6ceb5f4

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

src/doc/unstable-book/src/library-features/hint-core-should-pause.md renamed to src/doc/unstable-book/src/library-features/spin-loop-hint.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# `hint_core_should_pause`
1+
# `spin_loop_hint`
22

33
The tracking issue for this feature is: [#41196]
44

@@ -23,7 +23,7 @@ fn spin_loop(value: &AtomicBool) {
2323
These programs can be improved in performance like so:
2424

2525
```rust,no_run
26-
#![feature(hint_core_should_pause)]
26+
#![feature(spin_loop_hint)]
2727
use std::sync::atomic;
2828
use std::sync::atomic::{AtomicBool,Ordering};
2929
@@ -32,10 +32,10 @@ fn spin_loop(value: &AtomicBool) {
3232
if value.load(Ordering::Acquire) {
3333
break;
3434
}
35-
atomic::hint_core_should_pause();
35+
atomic::spin_loop_hint();
3636
}
3737
}
3838
```
3939

40-
Further improvements could combine `hint_core_should_pause` with
40+
Further improvements could combine `spin_loop_hint` with
4141
exponential backoff or `std::thread::yield_now`.

src/libcore/sync/atomic.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,8 @@ use fmt;
103103
///
104104
/// On some platforms this function may not do anything at all.
105105
#[inline]
106-
#[unstable(feature = "hint_core_should_pause", issue = "41196")]
107-
pub fn hint_core_should_pause()
108-
{
106+
#[stable(feature = "spin_loop_hint", since = "1.23.0")]
107+
pub fn spin_loop_hint() {
109108
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
110109
unsafe {
111110
asm!("pause" ::: "memory" : "volatile");

0 commit comments

Comments
 (0)