std::sync::atomic::compiler_fence

Function std::sync::atomic::compiler_fence

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.

© 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

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部