Function std::sync::atomic::compiler_fence [] [src]

pub fn compiler_fence(order: Ordering)
🔬 This is a nightly-only experimental API. (compiler_fences #41091)

A compiler memory fence.

compiler_fence does not emit any machine code, but prevents the compiler from re-ordering memory operations across this point. Which reorderings are disallowed is dictated by the given Ordering. Note that compiler_fence does not introduce inter-thread memory synchronization; for that, a fence is needed.

The re-ordering prevented by the different ordering semantics are:

Panics

Panics if order is Relaxed.