# 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:

- with `SeqCst`, no re-ordering of reads and writes across this point is allowed.
- with `Release`, preceding reads and writes cannot be moved past subsequent writes.
- with `Acquire`, subsequent reads and writes cannot be moved ahead of preceding reads.
- with `AcqRel`, both of the above rules are enforced.

# Panics

Panics if `order` is `Relaxed`.

# Help

## Keyboard Shortcuts

?
  Show this help dialog
S
  Focus the search field
⇤
  Move up in search results
⇥
  Move down in search results
⏎
  Go to active search result
+
  Collapse/expand all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g. `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g. `vec -> usize` or `* -> vec`)