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.5 by jsr166, Wed Aug 10 01:29:45 2011 UTC vs.
Revision 1.11 by jsr166, Tue Oct 25 19:21:27 2011 UTC

# Line 25 | Line 25 | import static java.lang.Double.longBitsT
25   * which differs from both the primitive double {@code ==} operator
26   * and from {@link Double#equals}, as if implemented by:
27   *  <pre> {@code
28 < * boolean bitEquals(double x, double y) {
28 > * static boolean bitEquals(double x, double y) {
29   *   long xBits = Double.doubleToRawLongBits(x);
30   *   long yBits = Double.doubleToRawLongBits(y);
31   *   return xBits == yBits;
32   * }}</pre>
33   *
34 + * @see jsr166e.DoubleAdder
35 + * @see jsr166e.DoubleMaxUpdater
36 + *
37   * @author Doug Lea
38   * @author Martin Buchholz
39   */
40   public class AtomicDouble extends Number implements java.io.Serializable {
41 <    static final long serialVersionUID = -8405198993435143622L;
41 >    private static final long serialVersionUID = -8405198993435143622L;
42  
43 <    private volatile long value;
43 >    private volatile transient long value;
44  
45      /**
46 <     * Creates a new AtomicDouble with the given initial value.
46 >     * Creates a new {@code AtomicDouble} with the given initial value.
47       *
48       * @param initialValue the initial value
49       */
# Line 49 | Line 52 | public class AtomicDouble extends Number
52      }
53  
54      /**
55 <     * Creates a new AtomicDouble with initial value {@code 0.0}.
55 >     * Creates a new {@code AtomicDouble} with initial value {@code 0.0}.
56       */
57 <    public AtomicDouble() { this(0.0); }
57 >    public AtomicDouble() {
58 >        // assert doubleToRawLongBits(0.0) == 0L;
59 >    }
60  
61      /**
62       * Gets the current value.
# Line 118 | Line 123 | public class AtomicDouble extends Number
123       * if the current value is <a href="#bitEquals">bitwise equal</a>
124       * to the expected value.
125       *
126 <     * <p>May <a href="package-summary.html#Spurious">fail spuriously</a>
126 >     * <p>May <a
127 >     * href="http://download.oracle.com/javase/7/docs/api/java/util/concurrent/atomic/package-summary.html#Spurious">
128 >     * fail spuriously</a>
129       * and does not provide ordering guarantees, so is only rarely an
130       * appropriate alternative to {@code compareAndSet}.
131       *
# Line 177 | Line 184 | public class AtomicDouble extends Number
184       * after a narrowing primitive conversion.
185       */
186      public int intValue() {
187 <        return (int)get();
187 >        return (int) get();
188      }
189  
190      /**
# Line 185 | Line 192 | public class AtomicDouble extends Number
192       * after a narrowing primitive conversion.
193       */
194      public long longValue() {
195 <        return (long)get();
195 >        return (long) get();
196      }
197  
198      /**
# Line 193 | Line 200 | public class AtomicDouble extends Number
200       * after a narrowing primitive conversion.
201       */
202      public float floatValue() {
203 <        return (float)get();
203 >        return (float) get();
204      }
205  
206      /**
# Line 203 | Line 210 | public class AtomicDouble extends Number
210          return get();
211      }
212  
213 +    /**
214 +     * Saves the state to a stream (that is, serializes it).
215 +     *
216 +     * @serialData The current value is emitted (a {@code double}).
217 +     */
218 +    private void writeObject(java.io.ObjectOutputStream s)
219 +        throws java.io.IOException{
220 +        s.defaultWriteObject();
221 +
222 +        s.writeDouble(get());
223 +    }
224 +
225 +    /**
226 +     * Reconstitutes the instance from a stream (that is, deserializes it).
227 +     */
228 +    private void readObject(java.io.ObjectInputStream s)
229 +        throws java.io.IOException, ClassNotFoundException {
230 +        s.defaultReadObject();
231 +
232 +        set(s.readDouble());
233 +    }
234 +
235      // Unsafe mechanics
236      private static final sun.misc.Unsafe unsafe = getUnsafe();
237      private static final long valueOffset;
# Line 241 | Line 270 | public class AtomicDouble extends Number
270              }
271          }
272      }
244
273   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines