diff options
| author | kennytm <kennytm@gmail.com> | 2017-11-28 03:16:43 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-11-28 03:16:43 +0800 |
| commit | aa99bd96fdbbe00e5aa96927c5edba908095527f (patch) | |
| tree | eda1cd008de6a39a1b4bfcce2bfdcae287673ea0 /src/doc | |
| parent | 2f012e4405c6d5bdd2855f3e1c416bd6e75808d8 (diff) | |
| parent | d5e8b61054018799c09d0e4c7166a6c4f198cbc5 (diff) | |
| download | rust-aa99bd96fdbbe00e5aa96927c5edba908095527f.tar.gz rust-aa99bd96fdbbe00e5aa96927c5edba908095527f.zip | |
Rollup merge of #46174 - stjepang:stabilize-spinloophint, r=sfackler
Stabilize spin_loop_hint Stabilize `spin_loop_hint` in release `1.23.0`. I've also renamed feature `hint_core_should_pause` to `spin_loop_hint`. cc #41196
Diffstat (limited to 'src/doc')
| -rw-r--r-- | src/doc/unstable-book/src/library-features/hint-core-should-pause.md | 41 |
1 files changed, 0 insertions, 41 deletions
diff --git a/src/doc/unstable-book/src/library-features/hint-core-should-pause.md b/src/doc/unstable-book/src/library-features/hint-core-should-pause.md deleted file mode 100644 index 05e057be493..00000000000 --- a/src/doc/unstable-book/src/library-features/hint-core-should-pause.md +++ /dev/null @@ -1,41 +0,0 @@ -# `hint_core_should_pause` - -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(hint_core_should_pause)] -use std::sync::atomic; -use std::sync::atomic::{AtomicBool,Ordering}; - -fn spin_loop(value: &AtomicBool) { - loop { - if value.load(Ordering::Acquire) { - break; - } - atomic::hint_core_should_pause(); - } -} -``` - -Further improvements could combine `hint_core_should_pause` with -exponential backoff or `std::thread::yield_now`. |
