Java Code Examples for java.util.concurrent.atomic.DoubleAdder#add()

The following examples show how to use java.util.concurrent.atomic.DoubleAdder#add() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DoubleAdderDemo.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
public void run() {
    phaser.arriveAndAwaitAdvance();
    phaser.arriveAndAwaitAdvance();
    DoubleAdder a = adder;
    for (int i = 0; i < incs; ++i)
        a.add(1.0);
    result = a.sum();
    phaser.arrive();
}
 
Example 2
Source File: DoubleAdderTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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());
}
 
Example 3
Source File: DoubleAdderDemo.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public void run() {
    phaser.arriveAndAwaitAdvance();
    phaser.arriveAndAwaitAdvance();
    DoubleAdder a = adder;
    for (int i = 0; i < incs; ++i)
        a.add(1.0);
    result = a.sum();
    phaser.arrive();
}
 
Example 4
Source File: DoubleAdderTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * add adds given value to current, and sum returns current value
 */
public void testAddAndSum() {
    DoubleAdder ai = new DoubleAdder();
    ai.add(2.0);
    assertEquals(2.0, ai.sum());
    ai.add(-4.0);
    assertEquals(-2.0, ai.sum());
}
 
Example 5
Source File: DoubleAdderTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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());
}
 
Example 6
Source File: DoubleAdderTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * reset() causes subsequent sum() to return zero
 */
public void testReset() {
    DoubleAdder ai = new DoubleAdder();
    ai.add(2.0);
    assertEquals(2.0, ai.sum());
    ai.reset();
    assertEquals(0.0, ai.sum());
}
 
Example 7
Source File: DoubleAdderTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * add adds given value to current, and sum returns current value
 */
public void testAddAndSum() {
    DoubleAdder ai = new DoubleAdder();
    ai.add(2.0);
    assertEquals(2.0, ai.sum());
    ai.add(-4.0);
    assertEquals(-2.0, ai.sum());
}
 
Example 8
Source File: Serial.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
static void testDoubleAdder() {
    DoubleAdder a = new DoubleAdder();
    a.add(20.1d);
    DoubleAdder result = echo(a);
    if (result.doubleValue() != a.doubleValue())
        throw new RuntimeException("Unexpected doubleValue");

    checkSerialClassName(a, "java.util.concurrent.atomic.DoubleAdder$SerializationProxy");
}
 
Example 9
Source File: DoubleAdderDemo.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public void run() {
    phaser.arriveAndAwaitAdvance();
    phaser.arriveAndAwaitAdvance();
    DoubleAdder a = adder;
    for (int i = 0; i < incs; ++i)
        a.add(1.0);
    result = a.sum();
    phaser.arrive();
}
 
Example 10
Source File: Serial.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
static void testDoubleAdder() {
    DoubleAdder a = new DoubleAdder();
    a.add(20.1d);
    DoubleAdder result = echo(a);
    if (result.doubleValue() != a.doubleValue())
        throw new RuntimeException("Unexpected doubleValue");

    checkSerialClassName(a, "java.util.concurrent.atomic.DoubleAdder$SerializationProxy");
}
 
Example 11
Source File: DoubleAdderDemo.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public void run() {
    phaser.arriveAndAwaitAdvance();
    phaser.arriveAndAwaitAdvance();
    DoubleAdder a = adder;
    for (int i = 0; i < incs; ++i)
        a.add(1.0);
    result = a.sum();
    phaser.arrive();
}
 
Example 12
Source File: Serial.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
static void testDoubleAdder() {
    DoubleAdder a = new DoubleAdder();
    a.add(20.1d);
    DoubleAdder result = echo(a);
    if (result.doubleValue() != a.doubleValue())
        throw new RuntimeException("Unexpected doubleValue");

    checkSerialClassName(a, "java.util.concurrent.atomic.DoubleAdder$SerializationProxy");
}
 
Example 13
Source File: Serial.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
static void testDoubleAdder() {
    DoubleAdder a = new DoubleAdder();
    a.add(20.1d);
    DoubleAdder result = echo(a);
    if (result.doubleValue() != a.doubleValue())
        throw new RuntimeException("Unexpected doubleValue");

    checkSerialClassName(a, "java.util.concurrent.atomic.DoubleAdder$SerializationProxy");
}
 
Example 14
Source File: DoubleAdderTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * toString returns current value.
 */
public void testToString() {
    DoubleAdder ai = new DoubleAdder();
    assertEquals(Double.toString(0.0), ai.toString());
    ai.add(1.0);
    assertEquals(Double.toString(1.0), ai.toString());
}
 
Example 15
Source File: DoubleAdderDemo.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public void run() {
    phaser.arriveAndAwaitAdvance();
    phaser.arriveAndAwaitAdvance();
    DoubleAdder a = adder;
    for (int i = 0; i < incs; ++i)
        a.add(1.0);
    result = a.sum();
    phaser.arrive();
}
 
Example 16
Source File: Serial.java    From native-obfuscator with GNU General Public License v3.0 5 votes vote down vote up
static void testDoubleAdder() {
    DoubleAdder a = new DoubleAdder();
    a.add(20.1d);
    DoubleAdder result = echo(a);
    if (result.doubleValue() != a.doubleValue())
        throw new RuntimeException("Unexpected doubleValue");

    checkSerialClassName(a, "java.util.concurrent.atomic.DoubleAdder$SerializationProxy");
}
 
Example 17
Source File: DoubleAdderDemo.java    From native-obfuscator with GNU General Public License v3.0 5 votes vote down vote up
public void run() {
    phaser.arriveAndAwaitAdvance();
    phaser.arriveAndAwaitAdvance();
    DoubleAdder a = adder;
    for (int i = 0; i < incs; ++i)
        a.add(1.0);
    result = a.sum();
    phaser.arrive();
}
 
Example 18
Source File: DoubleAdderTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * intValue returns current value.
 */
public void testIntValue() {
    DoubleAdder ai = new DoubleAdder();
    assertEquals(0, ai.intValue());
    ai.add(1.0);
    assertEquals(1, ai.intValue());
}
 
Example 19
Source File: Serial.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
static void testDoubleAdder() {
    DoubleAdder a = new DoubleAdder();
    a.add(20.1d);
    DoubleAdder result = echo(a);
    if (result.doubleValue() != a.doubleValue())
        throw new RuntimeException("Unexpected doubleValue");

    checkSerialClassName(a, "java.util.concurrent.atomic.DoubleAdder$SerializationProxy");
}
 
Example 20
Source File: DoubleAdderDemo.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public void run() {
    phaser.arriveAndAwaitAdvance();
    phaser.arriveAndAwaitAdvance();
    DoubleAdder a = adder;
    for (int i = 0; i < incs; ++i)
        a.add(1.0);
    result = a.sum();
    phaser.arrive();
}