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

Comparing jsr166/src/jsr166e/DoubleAdder.java (file contents):
Revision 1.8 by jsr166, Mon Jan 7 07:14:01 2013 UTC vs.
Revision 1.11 by dl, Sun May 4 22:38:19 2014 UTC

# Line 59 | Line 59 | public class DoubleAdder extends Striped
59       * @param x the value to add
60       */
61      public void add(double x) {
62 <        Cell[] as; long b, v; HashCode hc; Cell a; int n;
62 >        Cell[] as; long b, v; int[] hc; Cell a; int n;
63          if ((as = cells) != null ||
64              !casBase(b = base,
65                       Double.doubleToRawLongBits
66                       (Double.longBitsToDouble(b) + x))) {
67              boolean uncontended = true;
68 <            int h = (hc = threadHashCode.get()).code;
69 <            if (as == null || (n = as.length) < 1 ||
70 <                (a = as[(n - 1) & h]) == null ||
68 >            if ((hc = threadHashCode.get()) == null ||
69 >                as == null || (n = as.length) < 1 ||
70 >                (a = as[(n - 1) & hc[0]]) == null ||
71                  !(uncontended = a.cas(v = a.value,
72                                        Double.doubleToRawLongBits
73                                        (Double.longBitsToDouble(v) + x))))
# Line 77 | Line 77 | public class DoubleAdder extends Striped
77  
78      /**
79       * Returns the current sum.  The returned value is <em>NOT</em> an
80 <     * atomic snapshot: invocation in the absence of concurrent
80 >     * atomic snapshot; invocation in the absence of concurrent
81       * updates returns an accurate result, but concurrent updates that
82       * occur while the sum is being calculated might not be
83 <     * incorporated.  Also, because double-precision arithmetic is not
83 >     * incorporated.  Also, because floating-point arithmetic is not
84       * strictly associative, the returned result need not be identical
85       * to the value that would be obtained in a sequential series of
86       * updates to a single variable.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines