use of java8.util.concurrent.atomic.DoubleAdder in project streamsupport by stefan-zobel.
the class DoubleAdderTest method testSumThenReset.
/**
* sumThenReset() returns sum; subsequent sum() returns zero
*/
public void testSumThenReset() {
DoubleAdder ai = new DoubleAdder();
ai.add(2.0);
assertEquals(2.0, ai.sum());
assertEquals(2.0, ai.sumThenReset());
assertEquals(0.0, ai.sum());
}
use of java8.util.concurrent.atomic.DoubleAdder in project streamsupport by stefan-zobel.
the class DoubleAdderTest method testIntValue.
/**
* intValue returns current value.
*/
public void testIntValue() {
DoubleAdder ai = new DoubleAdder();
assertEquals(0, ai.intValue());
ai.add(1.0);
assertEquals(1, ai.intValue());
}
use of java8.util.concurrent.atomic.DoubleAdder in project streamsupport by stefan-zobel.
the class DoubleAdderTest method testDoubleValue.
/**
* doubleValue returns current value.
*/
public void testDoubleValue() {
DoubleAdder ai = new DoubleAdder();
assertEquals(0.0, ai.doubleValue());
ai.add(1.0);
assertEquals(1.0, ai.doubleValue());
}
use of java8.util.concurrent.atomic.DoubleAdder in project streamsupport by stefan-zobel.
the class DoubleAdderTest method testConstructor.
/**
* default constructed initializes to zero
*/
public void testConstructor() {
DoubleAdder ai = new DoubleAdder();
assertEquals(0.0, ai.sum());
}
use of java8.util.concurrent.atomic.DoubleAdder in project streamsupport by stefan-zobel.
the class DoubleAdderDemo method adderTest.
static void adderTest(int nthreads, int incs) {
System.out.print("DoubleAdder ");
Phaser phaser = new Phaser(nthreads + 1);
DoubleAdder a = new DoubleAdder();
for (int i = 0; i < nthreads; ++i) pool.execute(new AdderTask(a, phaser, incs));
report(nthreads, incs, timeTasks(phaser), a.sum());
}
Aggregations