Skip to content

Commit f093d59

Browse files
committed
Address @parched's comments
1 parent e6597e1 commit f093d59

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

src/doc/unstable-book/src/compiler-barriers.md

+3-8
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ compiler is allowed to do. Specifically, depending on the given ordering
2222
semantics, the compiler may be disallowed from moving reads or writes
2323
from before or after the call to the other side of the call to
2424
`compiler_barrier`. Note that it does **not** prevent the *hardware*
25-
from doing such re-orderings -- for that, the `volatile_*` class of
26-
functions, or full memory fences, need to be used.
25+
from doing such re-ordering. This is not a problem in a single-threaded,
26+
execution context, but when other threads may modify memory at the same
27+
time, stronger synchronization primitives are required.
2728

2829
## Examples
2930

@@ -92,12 +93,6 @@ fn signal_handler() {
9293
}
9394
```
9495

95-
In more advanced cases (for example, if `IMPORTANT_VARIABLE` was an
96-
`AtomicPtr` that starts as `NULL`), it may also be unsafe for the
97-
compiler to hoist code using `IMPORTANT_VARIABLE` above the
98-
`IS_READY.load`. In that case, a `compiler_barrier(Ordering::Acquire)`
99-
should be placed at the top of the `if` to prevent this optimizations.
100-
10196
A deeper discussion of compiler barriers with various re-ordering
10297
semantics (such as `Ordering::SeqCst`) is beyond the scope of this text.
10398
Curious readers are encouraged to read the Linux kernel's discussion of

0 commit comments

Comments
 (0)