std::sync::atomic::compiler_fence
Function std::sync::atomic::compiler_fence
pub fn compiler_fence(order: Ordering)
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
.
© 2010 The Rust Project Developers
Licensed under the Apache License, Version 2.0 or the MIT license, at your option.
https://doc.rust-lang.org/std/sync/atomic/fn.compiler_fence.html