@@ -22,8 +22,9 @@ compiler is allowed to do. Specifically, depending on the given ordering
22
22
semantics, the compiler may be disallowed from moving reads or writes
23
23
from before or after the call to the other side of the call to
24
24
` 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.
27
28
28
29
## Examples
29
30
@@ -92,12 +93,6 @@ fn signal_handler() {
92
93
}
93
94
```
94
95
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
-
101
96
A deeper discussion of compiler barriers with various re-ordering
102
97
semantics (such as ` Ordering::SeqCst ` ) is beyond the scope of this text.
103
98
Curious readers are encouraged to read the Linux kernel's discussion of
0 commit comments