@Override public LongAddable get() { return new LongAdder(); } };
/** Equivalent to {@code add(1)}. */ public void increment() { add(1L); }
/** * Adds the given value. * * @param x the value to add */ public void add(long x) { Cell[] as; long b, v; int[] hc; Cell a; int n; if ((as = cells) != null || !casBase(b = base, b + x)) { boolean uncontended = true; if ((hc = threadHashCode.get()) == null || as == null || (n = as.length) < 1 || (a = as[(n - 1) & hc[0]]) == null || !(uncontended = a.cas(v = a.value, v + x))) retryUpdate(x, hc, uncontended); } }
/** Returns the {@link #sum} as a {@code float} after a widening primitive conversion. */ public float floatValue() { return (float) sum(); }
/** * Resets variables maintaining the sum to zero. This method may be a useful alternative to * creating a new adder, but is only effective if there are no concurrent updates. Because this * method is intrinsically racy, it should only be used when it is known that no threads are * concurrently updating. */ public void reset() { internalReset(0L); }
/** Returns the {@link #sum} as a {@code double} after a widening primitive conversion. */ public double doubleValue() { return (double) sum(); }
/** * Resets variables maintaining the sum to zero. This method may be a useful alternative to * creating a new adder, but is only effective if there are no concurrent updates. Because this * method is intrinsically racy, it should only be used when it is known that no threads are * concurrently updating. */ public void reset() { internalReset(0L); }
/** * Equivalent to {@link #sum}. * * @return the sum */ public long longValue() { return sum(); }
/** * Adds the given value. * * @param x the value to add */ public void add(long x) { Cell[] as; long b, v; int[] hc; Cell a; int n; if ((as = cells) != null || !casBase(b = base, b + x)) { boolean uncontended = true; if ((hc = threadHashCode.get()) == null || as == null || (n = as.length) < 1 || (a = as[(n - 1) & hc[0]]) == null || !(uncontended = a.cas(v = a.value, v + x))) retryUpdate(x, hc, uncontended); } }
/** Equivalent to {@code add(-1)}. */ public void decrement() { add(-1L); }
/** * Resets variables maintaining the sum to zero. This method may be a useful alternative to * creating a new adder, but is only effective if there are no concurrent updates. Because this * method is intrinsically racy, it should only be used when it is known that no threads are * concurrently updating. */ public void reset() { internalReset(0L); }
@Override public LongAddable get() { return new LongAdder(); } };
/** Returns the {@link #sum} as an {@code int} after a narrowing primitive conversion. */ public int intValue() { return (int) sum(); }
/** * Adds the given value. * * @param x the value to add */ public void add(long x) { Cell[] as; long b, v; int[] hc; Cell a; int n; if ((as = cells) != null || !casBase(b = base, b + x)) { boolean uncontended = true; if ((hc = threadHashCode.get()) == null || as == null || (n = as.length) < 1 || (a = as[(n - 1) & hc[0]]) == null || !(uncontended = a.cas(v = a.value, v + x))) retryUpdate(x, hc, uncontended); } }
/** Equivalent to {@code add(-1)}. */ public void decrement() { add(-1L); }
/** * Resets variables maintaining the sum to zero. This method may be a useful alternative to * creating a new adder, but is only effective if there are no concurrent updates. Because this * method is intrinsically racy, it should only be used when it is known that no threads are * concurrently updating. */ public void reset() { internalReset(0L); }
@Override public LongAddable get() { return new LongAdder(); } };
/** * Returns the String representation of the {@link #sum}. * * @return the String representation of the {@link #sum} */ public String toString() { return Long.toString(sum()); }
/** * Adds the given value. * * @param x the value to add */ public void add(long x) { Cell[] as; long b, v; int[] hc; Cell a; int n; if ((as = cells) != null || !casBase(b = base, b + x)) { boolean uncontended = true; if ((hc = threadHashCode.get()) == null || as == null || (n = as.length) < 1 || (a = as[(n - 1) & hc[0]]) == null || !(uncontended = a.cas(v = a.value, v + x))) retryUpdate(x, hc, uncontended); } }
/** Equivalent to {@code add(1)}. */ public void increment() { add(1L); }