98 */ |
98 */ |
99 public void accumulate(double x) { |
99 public void accumulate(double x) { |
100 Cell[] as; long b, v, r; int m; Cell a; |
100 Cell[] as; long b, v, r; int m; Cell a; |
101 if ((as = cells) != null || |
101 if ((as = cells) != null || |
102 (r = Double.doubleToRawLongBits |
102 (r = Double.doubleToRawLongBits |
103 (function.operateAsDouble |
103 (function.applyAsDouble |
104 (Double.longBitsToDouble(b = base), x))) != b && !casBase(b, r)) { |
104 (Double.longBitsToDouble(b = base), x))) != b && !casBase(b, r)) { |
105 boolean uncontended = true; |
105 boolean uncontended = true; |
106 if (as == null || (m = as.length - 1) < 0 || |
106 if (as == null || (m = as.length - 1) < 0 || |
107 (a = as[getProbe() & m]) == null || |
107 (a = as[getProbe() & m]) == null || |
108 !(uncontended = |
108 !(uncontended = |
109 (r = Double.doubleToRawLongBits |
109 (r = Double.doubleToRawLongBits |
110 (function.operateAsDouble |
110 (function.applyAsDouble |
111 (Double.longBitsToDouble(v = a.value), x))) == v || |
111 (Double.longBitsToDouble(v = a.value), x))) == v || |
112 a.cas(v, r))) |
112 a.cas(v, r))) |
113 doubleAccumulate(x, function, uncontended); |
113 doubleAccumulate(x, function, uncontended); |
114 } |
114 } |
115 } |
115 } |
127 Cell[] as = cells; Cell a; |
127 Cell[] as = cells; Cell a; |
128 double result = Double.longBitsToDouble(base); |
128 double result = Double.longBitsToDouble(base); |
129 if (as != null) { |
129 if (as != null) { |
130 for (int i = 0; i < as.length; ++i) { |
130 for (int i = 0; i < as.length; ++i) { |
131 if ((a = as[i]) != null) |
131 if ((a = as[i]) != null) |
132 result = function.operateAsDouble |
132 result = function.applyAsDouble |
133 (result, Double.longBitsToDouble(a.value)); |
133 (result, Double.longBitsToDouble(a.value)); |
134 } |
134 } |
135 } |
135 } |
136 return result; |
136 return result; |
137 } |
137 } |