5 |
|
*/ |
6 |
|
|
7 |
|
package jsr166e; |
8 |
+ |
|
9 |
+ |
import java.io.IOException; |
10 |
+ |
import java.io.ObjectInputStream; |
11 |
+ |
import java.io.ObjectOutputStream; |
12 |
|
import java.io.Serializable; |
13 |
|
|
14 |
|
/** |
63 |
|
* @param x the value to add |
64 |
|
*/ |
65 |
|
public void add(double x) { |
66 |
< |
Cell[] as; long b, v; HashCode hc; Cell a; int n; |
66 |
> |
Cell[] as; long b, v; int[] hc; Cell a; int n; |
67 |
|
if ((as = cells) != null || |
68 |
|
!casBase(b = base, |
69 |
|
Double.doubleToRawLongBits |
70 |
|
(Double.longBitsToDouble(b) + x))) { |
71 |
|
boolean uncontended = true; |
72 |
< |
int h = (hc = threadHashCode.get()).code; |
73 |
< |
if (as == null || (n = as.length) < 1 || |
74 |
< |
(a = as[(n - 1) & h]) == null || |
72 |
> |
if ((hc = threadHashCode.get()) == null || |
73 |
> |
as == null || (n = as.length) < 1 || |
74 |
> |
(a = as[(n - 1) & hc[0]]) == null || |
75 |
|
!(uncontended = a.cas(v = a.value, |
76 |
|
Double.doubleToRawLongBits |
77 |
|
(Double.longBitsToDouble(v) + x)))) |
185 |
|
return (float)sum(); |
186 |
|
} |
187 |
|
|
188 |
< |
private void writeObject(java.io.ObjectOutputStream s) |
185 |
< |
throws java.io.IOException { |
188 |
> |
private void writeObject(ObjectOutputStream s) throws IOException { |
189 |
|
s.defaultWriteObject(); |
190 |
|
s.writeDouble(sum()); |
191 |
|
} |
192 |
|
|
193 |
< |
private void readObject(java.io.ObjectInputStream s) |
194 |
< |
throws java.io.IOException, ClassNotFoundException { |
193 |
> |
private void readObject(ObjectInputStream s) |
194 |
> |
throws IOException, ClassNotFoundException { |
195 |
|
s.defaultReadObject(); |
196 |
|
busy = 0; |
197 |
|
cells = null; |