ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/jsr166e/extra/AtomicDouble.java
(Generate patch)

Comparing jsr166/src/jsr166e/extra/AtomicDouble.java (file contents):
Revision 1.3 by jsr166, Tue Aug 9 08:28:54 2011 UTC vs.
Revision 1.4 by jsr166, Tue Aug 9 19:10:29 2011 UTC

# Line 39 | Line 39 | public class AtomicDouble extends Number
39      private static final sun.misc.Unsafe unsafe = getUnsafe();
40      private static final long valueOffset;
41  
42    /**
43     * Records whether the underlying JVM supports lockless
44     * compareAndSwap for longs. While the Unsafe.compareAndSwapLong
45     * method works in either case, some constructions should be
46     * handled at Java level to avoid locking user-visible locks.
47     */
48    static final boolean VM_SUPPORTS_LONG_CAS = VMSupportsCS8();
49
50    /**
51     * Returns whether underlying JVM supports lockless CompareAndSet
52     * for longs. Called only once and cached in VM_SUPPORTS_LONG_CAS.
53     */
54    private static boolean VMSupportsCS8() {
55        final Class<?> klazz = java.util.concurrent.atomic.AtomicLong.class;
56        return java.security.AccessController.doPrivileged
57            (new java.security.PrivilegedAction<Boolean>() {
58                public Boolean run() {
59                    try {
60                        java.lang.reflect.Method m =
61                            klazz.getDeclaredMethod("VMSupportsCS8", new Class<?>[0]);
62                        m.setAccessible(true);
63                        return (Boolean) m.invoke(new Class<?>[0]);
64                    } catch (Throwable t) { throw new Error(t); }
65                }});
66    }
67
42      static {
43          try {
44              valueOffset = unsafe.objectFieldOffset

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines