Tabnine Logo
LongAdder
Code IndexAdd Tabnine to your IDE (free)

How to use
LongAdder
in
com.google.common.hash

Best Java code snippets using com.google.common.hash.LongAdder (Showing top 20 results out of 315)

origin: google/guava

 @Override
 public LongAddable get() {
  return new LongAdder();
 }
};
origin: google/guava

/** Equivalent to {@code add(1)}. */
public void increment() {
 add(1L);
}
origin: google/guava

/**
 * 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);
 }
}
origin: google/guava

/** Returns the {@link #sum} as a {@code float} after a widening primitive conversion. */
public float floatValue() {
 return (float) sum();
}
origin: google/guava

/**
 * 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);
}
origin: google/guava

/** Returns the {@link #sum} as a {@code double} after a widening primitive conversion. */
public double doubleValue() {
 return (double) sum();
}
origin: google/j2objc

/**
 * 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);
}
origin: google/guava

/**
 * Equivalent to {@link #sum}.
 *
 * @return the sum
 */
public long longValue() {
 return sum();
}
origin: google/j2objc

/**
 * 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);
 }
}
origin: google/guava

/** Equivalent to {@code add(-1)}. */
public void decrement() {
 add(-1L);
}
origin: wildfly/wildfly

/**
 * 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);
}
origin: google/j2objc

 @Override
 public LongAddable get() {
  return new LongAdder();
 }
};
origin: google/guava

/** Returns the {@link #sum} as an {@code int} after a narrowing primitive conversion. */
public int intValue() {
 return (int) sum();
}
origin: wildfly/wildfly

/**
 * 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);
 }
}
origin: google/j2objc

/** Equivalent to {@code add(-1)}. */
public void decrement() {
 add(-1L);
}
origin: org.kill-bill.billing/killbill-platform-osgi-bundles-logger

/**
 * 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);
}
origin: wildfly/wildfly

 @Override
 public LongAddable get() {
  return new LongAdder();
 }
};
origin: google/guava

/**
 * Returns the String representation of the {@link #sum}.
 *
 * @return the String representation of the {@link #sum}
 */
public String toString() {
 return Long.toString(sum());
}
origin: org.jboss.eap/wildfly-client-all

/**
 * 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);
 }
}
origin: google/j2objc

/** Equivalent to {@code add(1)}. */
public void increment() {
 add(1L);
}
com.google.common.hashLongAdder

Javadoc

One or more variables that together maintain an initially zero long sum. When updates (method #add) are contended across threads, the set of variables may grow dynamically to reduce contention. Method #sum (or, equivalently, #longValue) returns the current total combined across the variables maintaining the sum.

This class is usually preferable to AtomicLong when multiple threads update a common sum that is used for purposes such as collecting statistics, not for fine-grained synchronization control. Under low update contention, the two classes have similar characteristics. But under high contention, expected throughput of this class is significantly higher, at the expense of higher space consumption.

This class extends Number, but does not define methods such as equals, hashCode and compareTo because instances are expected to be mutated, and so are not useful as collection keys.

jsr166e note: This class is targeted to be placed in java.util.concurrent.atomic.

Most used methods

  • <init>
    Creates a new adder with initial sum of zero.
  • add
    Adds the given value.
  • casBase
  • internalReset
  • retryUpdate
  • sum
    Returns the current sum. The returned value is NOT an atomic snapshot; invocation in the absence of

Popular in Java

  • Running tasks concurrently on multiple threads
  • putExtra (Intent)
  • getResourceAsStream (ClassLoader)
  • requestLocationUpdates (LocationManager)
  • BorderLayout (java.awt)
    A border layout lays out a container, arranging and resizing its components to fit in five regions:
  • BufferedImage (java.awt.image)
    The BufferedImage subclass describes an java.awt.Image with an accessible buffer of image data. All
  • PrintWriter (java.io)
    Wraps either an existing OutputStream or an existing Writerand provides convenience methods for prin
  • ResultSet (java.sql)
    An interface for an object which represents a database table entry, returned as the result of the qu
  • DateFormat (java.text)
    Formats or parses dates and times.This class provides factories for obtaining instances configured f
  • Executors (java.util.concurrent)
    Factory and utility methods for Executor, ExecutorService, ScheduledExecutorService, ThreadFactory,
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now