[jmm-dev] jdk9 APIs
boehm at acm.org
Thu Aug 27 17:06:40 UTC 2015
On Thu, Aug 27, 2015 at 4:30 AM, Doug Lea <dl at cs.oswego.edu> wrote:
> This would not accommodate a suggestion on valhalla list to automatically
> equate get/set to relaxed vs volatile versions depending on the
> of the field. Which is arguable anyway because it would require tracking
> the declaration site to determine memory semantics.
Purely from a programming perspective, I don't think this is what you want
anyway. I think one of the more common, and unusually safe, uses of
memory_order_relaxed in C++ is for non-racing accesses to atomic variables,
e.g. the second "check" in double-checked locking, or for reads of atomic
variables that are, in a sense, only hints and not trusted, e.g. the load
preceding a CAS. You really sometimes want plain gets on volatile data.
More information about the jmm-dev