use of java.util.concurrent.atomic.LongAdder in project jdk8u_jdk by JetBrains.
the class LongAdderDemo method adderTest.
static void adderTest(int nthreads, int incs) {
System.out.print("LongAdder ");
Phaser phaser = new Phaser(nthreads + 1);
LongAdder a = new LongAdder();
for (int i = 0; i < nthreads; ++i) pool.execute(new AdderTask(a, phaser, incs));
report(nthreads, incs, timeTasks(phaser), a.sum());
}
use of java.util.concurrent.atomic.LongAdder in project jdk8u_jdk by JetBrains.
the class Serial method testLongAdder.
static void testLongAdder() {
LongAdder a = new LongAdder();
a.add(45);
LongAdder result = echo(a);
if (result.longValue() != a.longValue())
throw new RuntimeException("Unexpected longValue");
checkSerialClassName(a, "java.util.concurrent.atomic.LongAdder$SerializationProxy");
}
use of java.util.concurrent.atomic.LongAdder in project jdk8u_jdk by JetBrains.
the class ThreadLocalRandomTest method testLongsCount.
/**
* A parallel sized stream of longs generates the given number of values
*/
public void testLongsCount() {
LongAdder counter = new LongAdder();
ThreadLocalRandom r = ThreadLocalRandom.current();
long size = 0;
for (int reps = 0; reps < REPS; ++reps) {
counter.reset();
r.longs(size).parallel().forEach(x -> {
counter.increment();
});
assertEquals(counter.sum(), size);
size += 524959;
}
}
use of java.util.concurrent.atomic.LongAdder in project XRTB by benmfaul.
the class CreativeProbe method getMap.
public List getMap() {
Map x = new HashMap();
List list = new ArrayList();
for (Map.Entry<String, LongAdder> entry : probes.entrySet()) {
String key = entry.getKey();
x = new HashMap();
x.put("name", key);
x.put("count", entry.getValue().sum());
list.add(x);
}
return list;
}
use of java.util.concurrent.atomic.LongAdder in project XRTB by benmfaul.
the class CreativeProbe method reset.
public void reset() {
probes = new HashMap();
total = new LongAdder();
bid = new LongAdder();
}
Aggregations