@@ -22,8 +22,9 @@ compiler is allowed to do. Specifically, depending on the given ordering
2222semantics, the compiler may be disallowed from moving reads or writes
2323from 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-
10196A deeper discussion of compiler barriers with various re-ordering
10297semantics (such as ` Ordering::SeqCst ` ) is beyond the scope of this text.
10398Curious readers are encouraged to read the Linux kernel's discussion of
0 commit comments