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

Comparing jsr166/src/jsr166e/LongAdder.java (file contents):
Revision 1.14 by jsr166, Mon Jan 14 02:02:41 2013 UTC vs.
Revision 1.17 by jsr166, Mon May 5 20:20:15 2014 UTC

# Line 5 | Line 5
5   */
6  
7   package jsr166e;
8 < import java.util.concurrent.atomic.AtomicLong;
8 >
9 > import java.io.IOException;
10 > import java.io.ObjectInputStream;
11 > import java.io.ObjectOutputStream;
12   import java.io.Serializable;
13 + import java.util.concurrent.atomic.AtomicLong;
14  
15   /**
16   * One or more variables that together maintain an initially zero
# Line 55 | Line 59 | public class LongAdder extends Striped64
59       * @param x the value to add
60       */
61      public void add(long 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 || !casBase(b = base, b + x)) {
64              boolean uncontended = true;
65 <            int h = (hc = threadHashCode.get()).code;
66 <            if (as == null || (n = as.length) < 1 ||
67 <                (a = as[(n - 1) & h]) == null ||
65 >            if ((hc = threadHashCode.get()) == null ||
66 >                as == null || (n = as.length) < 1 ||
67 >                (a = as[(n - 1) & hc[0]]) == null ||
68                  !(uncontended = a.cas(v = a.value, v + x)))
69                  retryUpdate(x, hc, uncontended);
70          }
# Line 182 | Line 186 | public class LongAdder extends Striped64
186          return (double)sum();
187      }
188  
189 <    private void writeObject(java.io.ObjectOutputStream s)
186 <        throws java.io.IOException {
189 >    private void writeObject(ObjectOutputStream s) throws IOException {
190          s.defaultWriteObject();
191          s.writeLong(sum());
192      }
193  
194 <    private void readObject(java.io.ObjectInputStream s)
195 <        throws java.io.IOException, ClassNotFoundException {
194 >    private void readObject(ObjectInputStream s)
195 >            throws IOException, ClassNotFoundException {
196          s.defaultReadObject();
197          busy = 0;
198          cells = null;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines