< prev index next >

src/java.base/share/classes/java/util/concurrent/atomic/LongAdder.java

Print this page
8234131: Miscellaneous changes imported from jsr166 CVS 2020-12
Reviewed-by: martin

*** 83,97 **** * @param x the value to add */ public void add(long x) { Cell[] cs; long b, v; int m; Cell c; if ((cs = cells) != null || !casBase(b = base, b + x)) { boolean uncontended = true; if (cs == null || (m = cs.length - 1) < 0 || ! (c = cs[getProbe() & m]) == null || !(uncontended = c.cas(v = c.value, v + x))) ! longAccumulate(x, null, uncontended); } } /** * Equivalent to {@code add(1)}. --- 83,98 ---- * @param x the value to add */ public void add(long x) { Cell[] cs; long b, v; int m; Cell c; if ((cs = cells) != null || !casBase(b = base, b + x)) { + int index = getProbe(); boolean uncontended = true; if (cs == null || (m = cs.length - 1) < 0 || ! (c = cs[index & m]) == null || !(uncontended = c.cas(v = c.value, v + x))) ! longAccumulate(x, null, uncontended, index); } } /** * Equivalent to {@code add(1)}.
< prev index next >