8074578: Document memory visibility effects of Unsafe compareAndSwap methods
authormartin
Wed, 04 Mar 2015 17:35:40 -0800
changeset 29715 ca3f43a932cf
parent 29714 afac043e9bf0
child 29716 838a9156720c
8074578: Document memory visibility effects of Unsafe compareAndSwap methods Reviewed-by: psandoz, jrose, dholmes
jdk/src/java.base/share/classes/sun/misc/Unsafe.java
--- a/jdk/src/java.base/share/classes/sun/misc/Unsafe.java	Tue Mar 10 14:23:03 2015 -0700
+++ b/jdk/src/java.base/share/classes/sun/misc/Unsafe.java	Wed Mar 04 17:35:40 2015 -0800
@@ -631,6 +631,10 @@
     /**
      * Atomically updates Java variable to {@code x} if it is currently
      * holding {@code expected}.
+     *
+     * <p>This operation has memory semantics of a {@code volatile} read
+     * and write.  Corresponds to C11 atomic_compare_exchange_strong.
+     *
      * @return {@code true} if successful
      */
     public final native boolean compareAndSwapObject(Object o, long offset,
@@ -640,6 +644,10 @@
     /**
      * Atomically updates Java variable to {@code x} if it is currently
      * holding {@code expected}.
+     *
+     * <p>This operation has memory semantics of a {@code volatile} read
+     * and write.  Corresponds to C11 atomic_compare_exchange_strong.
+     *
      * @return {@code true} if successful
      */
     public final native boolean compareAndSwapInt(Object o, long offset,
@@ -649,6 +657,10 @@
     /**
      * Atomically updates Java variable to {@code x} if it is currently
      * holding {@code expected}.
+     *
+     * <p>This operation has memory semantics of a {@code volatile} read
+     * and write.  Corresponds to C11 atomic_compare_exchange_strong.
+     *
      * @return {@code true} if successful
      */
     public final native boolean compareAndSwapLong(Object o, long offset,