Remove spin-loop-hint from the unstable book

This commit is contained in:
Stjepan Glavina 2017-11-22 11:24:57 +01:00
parent 6ceb5f4bec
commit a115fcd1a0

View file

@ -1,41 +0,0 @@
# `spin_loop_hint`
The tracking issue for this feature is: [#41196]
[#41196]: https://github.com/rust-lang/rust/issues/41196
------------------------
Many programs have spin loops like the following:
```rust,no_run
use std::sync::atomic::{AtomicBool,Ordering};
fn spin_loop(value: &AtomicBool) {
loop {
if value.load(Ordering::Acquire) {
break;
}
}
}
```
These programs can be improved in performance like so:
```rust,no_run
#![feature(spin_loop_hint)]
use std::sync::atomic;
use std::sync::atomic::{AtomicBool,Ordering};
fn spin_loop(value: &AtomicBool) {
loop {
if value.load(Ordering::Acquire) {
break;
}
atomic::spin_loop_hint();
}
}
```
Further improvements could combine `spin_loop_hint` with
exponential backoff or `std::thread::yield_now`.