So there is no memory_order_consume(C++11) in RUST?

I did not see it in "pub enum Ordering"

My understanding was that the consume ordering in C++ was never meaningfully implemented by any compiler (i.e. it’s optimized and codegen’d identically to acquire/release) due to specification issues that still have not been solved. See http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0750r1.html

So I always assumed (though I have no citation for this part) that it was intentionally omitted in Rust for now, and will likely be added if C++ ever gets a good enough fix for LLVM/Clang to implement.

5 Likes

This (consume) is in fact one reason why standard library Ordering is a non_exhaustive enum, so that we can add it later.

If you happen to have C++ code using consume that you need to port to Rust right now, it is always valid to replace consume with acquire, although it allows less optimization. In fact this is how LLVM/Clang implements it now: LLVM has no concept of consume, and Clang replaces consume with acquire.

1 Like