55 |
|
* @param x the value to add |
56 |
|
*/ |
57 |
|
public void add(long x) { |
58 |
< |
Cell[] as; long b, v; HashCode hc; Cell a; int n; |
58 |
> |
Cell[] as; long b, v; int[] hc; Cell a; int n; |
59 |
|
if ((as = cells) != null || !casBase(b = base, b + x)) { |
60 |
|
boolean uncontended = true; |
61 |
< |
int h = (hc = threadHashCode.get()).code; |
62 |
< |
if (as == null || (n = as.length) < 1 || |
63 |
< |
(a = as[(n - 1) & h]) == null || |
61 |
> |
if ((hc = threadHashCode.get()) == null || |
62 |
> |
as == null || (n = as.length) < 1 || |
63 |
> |
(a = as[(n - 1) & hc[0]]) == null || |
64 |
|
!(uncontended = a.cas(v = a.value, v + x))) |
65 |
|
retryUpdate(x, hc, uncontended); |
66 |
|
} |
82 |
|
|
83 |
|
/** |
84 |
|
* Returns the current sum. The returned value is <em>NOT</em> an |
85 |
< |
* atomic snapshot: invocation in the absence of concurrent |
85 |
> |
* atomic snapshot; invocation in the absence of concurrent |
86 |
|
* updates returns an accurate result, but concurrent updates that |
87 |
|
* occur while the sum is being calculated might not be |
88 |
|
* incorporated. |