Hi, My question is about the Java opaque memory order. E.g. the VarHandle.getOpaque or setOpaque.
Opaque doesn't provide ordering for surrounding loads/stores to different addresses. It will ensure coherence (so loads/stores to the same address can't be reordered). Example: https://github.com/openjdk/jcstress/blob/master/jcstress-samples/src/main/java/org/openjdk/jcstress/samples/jmm/basic/BasicJMM_05_Coherence.java Opaque will provide visibility and atomicity. Opaque is great for performance counters or progress indicators assuming there is no reliance on any other fields before or after that counter. It can be used in similar situations as memory_order_relaxed from C++. AFAIK opaque can be implemented by just inserting a compiler barrier since all modern CPUs are coherent and will ensure that stores become visible eventually. The question is the following: assuming that an opaque field is used appropriately, is there any risk in using opaque? Is there any chance that a JVM will go up in flames or start to take over the world. -- You received this message because you are subscribed to the Google Groups "mechanical-sympathy" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion, visit https://groups.google.com/d/msgid/mechanical-sympathy/CAGuAWdDMUDzNNSnc064Tt94mdi%2BvxeYBtVbNCX1jdP7q8U4tCg%40mail.gmail.com.
