equal
deleted
inserted
replaced
99 * @param x the value |
99 * @param x the value |
100 */ |
100 */ |
101 public void accumulate(long x) { |
101 public void accumulate(long x) { |
102 Cell[] as; long b, v, r; int m; Cell a; |
102 Cell[] as; long b, v, r; int m; Cell a; |
103 if ((as = cells) != null || |
103 if ((as = cells) != null || |
104 (r = function.operateAsLong(b = base, x)) != b && !casBase(b, r)) { |
104 (r = function.applyAsLong(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 = function.operateAsLong(v = a.value, x)) == v || |
109 (r = function.applyAsLong(v = a.value, x)) == v || |
110 a.cas(v, r))) |
110 a.cas(v, r))) |
111 longAccumulate(x, function, uncontended); |
111 longAccumulate(x, function, uncontended); |
112 } |
112 } |
113 } |
113 } |
114 |
114 |
125 Cell[] as = cells; Cell a; |
125 Cell[] as = cells; Cell a; |
126 long result = base; |
126 long result = base; |
127 if (as != null) { |
127 if (as != null) { |
128 for (int i = 0; i < as.length; ++i) { |
128 for (int i = 0; i < as.length; ++i) { |
129 if ((a = as[i]) != null) |
129 if ((a = as[i]) != null) |
130 result = function.operateAsLong(result, a.value); |
130 result = function.applyAsLong(result, a.value); |
131 } |
131 } |
132 } |
132 } |
133 return result; |
133 return result; |
134 } |
134 } |
135 |
135 |
169 if (as != null) { |
169 if (as != null) { |
170 for (int i = 0; i < as.length; ++i) { |
170 for (int i = 0; i < as.length; ++i) { |
171 if ((a = as[i]) != null) { |
171 if ((a = as[i]) != null) { |
172 long v = a.value; |
172 long v = a.value; |
173 a.value = identity; |
173 a.value = identity; |
174 result = function.operateAsLong(result, v); |
174 result = function.applyAsLong(result, v); |
175 } |
175 } |
176 } |
176 } |
177 } |
177 } |
178 return result; |
178 return result; |
179 } |
179 } |