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

Comparing jsr166/src/jsr166e/LongMaxUpdater.java (file contents):
Revision 1.2 by jsr166, Sat Sep 10 01:38:28 2011 UTC vs.
Revision 1.9 by dl, Sun May 4 22:38:19 2014 UTC

# Line 5 | Line 5
5   */
6  
7   package jsr166e;
8 import java.io.IOException;
8   import java.io.Serializable;
10 import java.io.ObjectInputStream;
11 import java.io.ObjectOutputStream;
9  
10   /**
11   * One or more variables that together maintain a running {@code long}
# Line 19 | Line 16 | import java.io.ObjectOutputStream;
16   * maximum across the variables maintaining updates.
17   *
18   * <p>This class extends {@link Number}, but does <em>not</em> define
19 < * methods such as {@code hashCode} and {@code compareTo} because
20 < * instances are expected to be mutated, and so are not useful as
21 < * collection keys.
19 > * methods such as {@code equals}, {@code hashCode} and {@code
20 > * compareTo} because instances are expected to be mutated, and so are
21 > * not useful as collection keys.
22   *
23   * <p><em>jsr166e note: This class is targeted to be placed in
24 < * java.util.concurrent.atomic<em>
24 > * java.util.concurrent.atomic.</em>
25   *
26   * @since 1.8
27   * @author Doug Lea
# Line 51 | Line 48 | public class LongMaxUpdater extends Stri
48       * @param x the value to update
49       */
50      public void update(long x) {
51 <        Cell[] as; long b, v; HashCode hc; Cell a; int n;
51 >        Cell[] as; long b, v; int[] hc; Cell a; int n;
52          if ((as = cells) != null ||
53              (b = base) < x && !casBase(b, x)) {
54              boolean uncontended = true;
55 <            int h = (hc = threadHashCode.get()).code;
56 <            if (as == null || (n = as.length) < 1 ||
57 <                (a = as[(n - 1) & h]) == null ||
55 >            if ((hc = threadHashCode.get()) == null ||
56 >                as == null || (n = as.length) < 1 ||
57 >                (a = as[(n - 1) & hc[0]]) == null ||
58                  ((v = a.value) < x && !(uncontended = a.cas(v, x))))
59                  retryUpdate(x, hc, uncontended);
60          }
# Line 65 | Line 62 | public class LongMaxUpdater extends Stri
62  
63      /**
64       * Returns the current maximum.  The returned value is
65 <     * <em>NOT</em> an atomic snapshot: Invocation in the absence of
65 >     * <em>NOT</em> an atomic snapshot; invocation in the absence of
66       * concurrent updates returns an accurate result, but concurrent
67       * updates that occur while the value is being calculated might
68       * not be incorporated.
# Line 130 | Line 127 | public class LongMaxUpdater extends Stri
127  
128      /**
129       * Returns the String representation of the {@link #max}.
130 <     * @return the String representation of the {@link #max}.
130 >     * @return the String representation of the {@link #max}
131       */
132      public String toString() {
133          return Long.toString(max());
# Line 175 | Line 172 | public class LongMaxUpdater extends Stri
172          s.writeLong(max());
173      }
174  
175 <    private void readObject(ObjectInputStream s)
176 <        throws IOException, ClassNotFoundException {
175 >    private void readObject(java.io.ObjectInputStream s)
176 >        throws java.io.IOException, ClassNotFoundException {
177          s.defaultReadObject();
178          busy = 0;
179          cells = null;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines