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

Comparing jsr166/src/jsr166e/ConcurrentHashMapV8.java (file contents):
Revision 1.86 by jsr166, Sun Jan 6 20:05:51 2013 UTC vs.
Revision 1.91 by jsr166, Mon Jan 28 06:58:51 2013 UTC

# Line 1785 | Line 1785 | public class ConcurrentHashMapV8<K, V>
1785                              }
1786                          }
1787                          if (len != 0) {
1788 <                            if (len > 1)
1788 >                            if (len > 1) {
1789                                  addCount(delta, len);
1790 +                                delta = 0L;
1791 +                            }
1792                              break;
1793                          }
1794                      }
# Line 3371 | Line 3373 | public class ConcurrentHashMapV8<K, V>
3373       * of each (key, value).
3374       *
3375       * @param transformer a function returning the transformation
3376 <     * for an element, or null of there is no transformation (in
3376 >     * for an element, or null if there is no transformation (in
3377       * which case the action is not applied).
3378       * @param action the action
3379       */
# Line 3415 | Line 3417 | public class ConcurrentHashMapV8<K, V>
3417       * combine values, or null if none.
3418       *
3419       * @param transformer a function returning the transformation
3420 <     * for an element, or null of there is no transformation (in
3420 >     * for an element, or null if there is no transformation (in
3421       * which case it is not combined).
3422       * @param reducer a commutative associative combining function
3423       * @return the result of accumulating the given transformation
# Line 3528 | Line 3530 | public class ConcurrentHashMapV8<K, V>
3530       * of each key.
3531       *
3532       * @param transformer a function returning the transformation
3533 <     * for an element, or null of there is no transformation (in
3533 >     * for an element, or null if there is no transformation (in
3534       * which case the action is not applied).
3535       * @param action the action
3536       */
# Line 3593 | Line 3595 | public class ConcurrentHashMapV8<K, V>
3595       * null if none.
3596       *
3597       * @param transformer a function returning the transformation
3598 <     * for an element, or null of there is no transformation (in
3598 >     * for an element, or null if there is no transformation (in
3599       * which case it is not combined).
3600       * @param reducer a commutative associative combining function
3601       * @return the result of accumulating the given transformation
# Line 3706 | Line 3708 | public class ConcurrentHashMapV8<K, V>
3708       * of each value.
3709       *
3710       * @param transformer a function returning the transformation
3711 <     * for an element, or null of there is no transformation (in
3711 >     * for an element, or null if there is no transformation (in
3712       * which case the action is not applied).
3713       */
3714      public <U> void forEachValueSequentially
# Line 3766 | Line 3768 | public class ConcurrentHashMapV8<K, V>
3768       * null if none.
3769       *
3770       * @param transformer a function returning the transformation
3771 <     * for an element, or null of there is no transformation (in
3771 >     * for an element, or null if there is no transformation (in
3772       * which case it is not combined).
3773       * @param reducer a commutative associative combining function
3774       * @return the result of accumulating the given transformation
# Line 3880 | Line 3882 | public class ConcurrentHashMapV8<K, V>
3882       * of each entry.
3883       *
3884       * @param transformer a function returning the transformation
3885 <     * for an element, or null of there is no transformation (in
3885 >     * for an element, or null if there is no transformation (in
3886       * which case the action is not applied).
3887       * @param action the action
3888       */
# Line 3943 | Line 3945 | public class ConcurrentHashMapV8<K, V>
3945       * or null if none.
3946       *
3947       * @param transformer a function returning the transformation
3948 <     * for an element, or null of there is no transformation (in
3948 >     * for an element, or null if there is no transformation (in
3949       * which case it is not combined).
3950       * @param reducer a commutative associative combining function
3951       * @return the result of accumulating the given transformation
# Line 4055 | Line 4057 | public class ConcurrentHashMapV8<K, V>
4057       * of each (key, value).
4058       *
4059       * @param transformer a function returning the transformation
4060 <     * for an element, or null of there is no transformation (in
4060 >     * for an element, or null if there is no transformation (in
4061       * which case the action is not applied).
4062       * @param action the action
4063       */
# Line 4090 | Line 4092 | public class ConcurrentHashMapV8<K, V>
4092       * combine values, or null if none.
4093       *
4094       * @param transformer a function returning the transformation
4095 <     * for an element, or null of there is no transformation (in
4095 >     * for an element, or null if there is no transformation (in
4096       * which case it is not combined).
4097       * @param reducer a commutative associative combining function
4098       * @return the result of accumulating the given transformation
# Line 4178 | Line 4180 | public class ConcurrentHashMapV8<K, V>
4180       * of each key.
4181       *
4182       * @param transformer a function returning the transformation
4183 <     * for an element, or null of there is no transformation (in
4183 >     * for an element, or null if there is no transformation (in
4184       * which case the action is not applied).
4185       * @param action the action
4186       */
# Line 4227 | Line 4229 | public class ConcurrentHashMapV8<K, V>
4229       * null if none.
4230       *
4231       * @param transformer a function returning the transformation
4232 <     * for an element, or null of there is no transformation (in
4232 >     * for an element, or null if there is no transformation (in
4233       * which case it is not combined).
4234       * @param reducer a commutative associative combining function
4235       * @return the result of accumulating the given transformation
# Line 4315 | Line 4317 | public class ConcurrentHashMapV8<K, V>
4317       * of each value.
4318       *
4319       * @param transformer a function returning the transformation
4320 <     * for an element, or null of there is no transformation (in
4320 >     * for an element, or null if there is no transformation (in
4321       * which case the action is not applied).
4322       */
4323      public <U> void forEachValueInParallel
# Line 4362 | Line 4364 | public class ConcurrentHashMapV8<K, V>
4364       * null if none.
4365       *
4366       * @param transformer a function returning the transformation
4367 <     * for an element, or null of there is no transformation (in
4367 >     * for an element, or null if there is no transformation (in
4368       * which case it is not combined).
4369       * @param reducer a commutative associative combining function
4370       * @return the result of accumulating the given transformation
# Line 4450 | Line 4452 | public class ConcurrentHashMapV8<K, V>
4452       * of each entry.
4453       *
4454       * @param transformer a function returning the transformation
4455 <     * for an element, or null of there is no transformation (in
4455 >     * for an element, or null if there is no transformation (in
4456       * which case the action is not applied).
4457       * @param action the action
4458       */
# Line 4498 | Line 4500 | public class ConcurrentHashMapV8<K, V>
4500       * or null if none.
4501       *
4502       * @param transformer a function returning the transformation
4503 <     * for an element, or null of there is no transformation (in
4503 >     * for an element, or null if there is no transformation (in
4504       * which case it is not combined).
4505       * @param reducer a commutative associative combining function
4506       * @return the result of accumulating the given transformation
# Line 4577 | Line 4579 | public class ConcurrentHashMapV8<K, V>
4579      /**
4580       * Base class for views.
4581       */
4582 <    static abstract class CHMView<K, V> {
4582 >    abstract static class CHMView<K, V> {
4583          final ConcurrentHashMapV8<K, V> map;
4584          CHMView(ConcurrentHashMapV8<K, V> map)  { this.map = map; }
4585  
# Line 4593 | Line 4595 | public class ConcurrentHashMapV8<K, V>
4595          public final void clear()               { map.clear(); }
4596  
4597          // implementations below rely on concrete classes supplying these
4598 <        abstract public Iterator<?> iterator();
4599 <        abstract public boolean contains(Object o);
4600 <        abstract public boolean remove(Object o);
4598 >        public abstract Iterator<?> iterator();
4599 >        public abstract boolean contains(Object o);
4600 >        public abstract boolean remove(Object o);
4601  
4602          private static final String oomeMsg = "Required array size too large";
4603  
# Line 6804 | Line 6806 | public class ConcurrentHashMapV8<K, V>
6806      private static final int ASHIFT;
6807  
6808      static {
6807        int ss;
6809          try {
6810              U = getUnsafe();
6811              Class<?> k = ConcurrentHashMapV8.class;
# Line 6823 | Line 6824 | public class ConcurrentHashMapV8<K, V>
6824                  (ck.getDeclaredField("value"));
6825              Class<?> sc = Node[].class;
6826              ABASE = U.arrayBaseOffset(sc);
6827 <            ss = U.arrayIndexScale(sc);
6828 <            ASHIFT = 31 - Integer.numberOfLeadingZeros(ss);
6827 >            int scale = U.arrayIndexScale(sc);
6828 >            if ((scale & (scale - 1)) != 0)
6829 >                throw new Error("data type scale not a power of two");
6830 >            ASHIFT = 31 - Integer.numberOfLeadingZeros(scale);
6831          } catch (Exception e) {
6832              throw new Error(e);
6833          }
6831        if ((ss & (ss-1)) != 0)
6832            throw new Error("data type scale not a power of two");
6834      }
6835  
6836      /**
# Line 6842 | Line 6843 | public class ConcurrentHashMapV8<K, V>
6843      private static sun.misc.Unsafe getUnsafe() {
6844          try {
6845              return sun.misc.Unsafe.getUnsafe();
6846 <        } catch (SecurityException se) {
6847 <            try {
6848 <                return java.security.AccessController.doPrivileged
6849 <                    (new java.security
6850 <                     .PrivilegedExceptionAction<sun.misc.Unsafe>() {
6851 <                        public sun.misc.Unsafe run() throws Exception {
6852 <                            java.lang.reflect.Field f = sun.misc
6853 <                                .Unsafe.class.getDeclaredField("theUnsafe");
6854 <                            f.setAccessible(true);
6855 <                            return (sun.misc.Unsafe) f.get(null);
6856 <                        }});
6857 <            } catch (java.security.PrivilegedActionException e) {
6858 <                throw new RuntimeException("Could not initialize intrinsics",
6859 <                                           e.getCause());
6860 <            }
6846 >        } catch (SecurityException tryReflectionInstead) {}
6847 >        try {
6848 >            return java.security.AccessController.doPrivileged
6849 >            (new java.security.PrivilegedExceptionAction<sun.misc.Unsafe>() {
6850 >                public sun.misc.Unsafe run() throws Exception {
6851 >                    Class<sun.misc.Unsafe> k = sun.misc.Unsafe.class;
6852 >                    for (java.lang.reflect.Field f : k.getDeclaredFields()) {
6853 >                        f.setAccessible(true);
6854 >                        Object x = f.get(null);
6855 >                        if (k.isInstance(x))
6856 >                            return k.cast(x);
6857 >                    }
6858 >                    throw new NoSuchFieldError("the Unsafe");
6859 >                }});
6860 >        } catch (java.security.PrivilegedActionException e) {
6861 >            throw new RuntimeException("Could not initialize intrinsics",
6862 >                                       e.getCause());
6863          }
6864      }
6865   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines