Java Code Examples for java.util.concurrent.atomic.DoubleAccumulator#reset()

The following examples show how to use java.util.concurrent.atomic.DoubleAccumulator#reset() . 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: Serial.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
static void testDoubleAccumulator() {
    DoubleBinaryOperator plus = (DoubleBinaryOperator & Serializable) (x, y) -> x + y;
    DoubleAccumulator a = new DoubleAccumulator(plus, 13.9d);
    a.accumulate(17.5d);
    DoubleAccumulator result = echo(a);
    if (result.get() != a.get())
        throw new RuntimeException("Unexpected value");
    a.reset();
    result.reset();
    if (result.get() != a.get())
        throw new RuntimeException("Unexpected value after reset");

    checkSerialClassName(a, "java.util.concurrent.atomic.DoubleAccumulator$SerializationProxy");
}
 
Example 2
Source File: Serial.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
static void testDoubleAccumulator() {
    DoubleBinaryOperator plus = (DoubleBinaryOperator & Serializable) (x, y) -> x + y;
    DoubleAccumulator a = new DoubleAccumulator(plus, 13.9d);
    a.accumulate(17.5d);
    DoubleAccumulator result = echo(a);
    if (result.get() != a.get())
        throw new RuntimeException("Unexpected value");
    a.reset();
    result.reset();
    if (result.get() != a.get())
        throw new RuntimeException("Unexpected value after reset");

    checkSerialClassName(a, "java.util.concurrent.atomic.DoubleAccumulator$SerializationProxy");
}
 
Example 3
Source File: Serial.java    From native-obfuscator with GNU General Public License v3.0 5 votes vote down vote up
static void testDoubleAccumulator() {
    DoubleBinaryOperator plus = (DoubleBinaryOperator & Serializable) (x, y) -> x + y;
    DoubleAccumulator a = new DoubleAccumulator(plus, 13.9d);
    a.accumulate(17.5d);
    DoubleAccumulator result = echo(a);
    if (result.get() != a.get())
        throw new RuntimeException("Unexpected value");
    a.reset();
    result.reset();
    if (result.get() != a.get())
        throw new RuntimeException("Unexpected value after reset");

    checkSerialClassName(a, "java.util.concurrent.atomic.DoubleAccumulator$SerializationProxy");
}
 
Example 4
Source File: Serial.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
static void testDoubleAccumulator() {
    DoubleBinaryOperator plus = (DoubleBinaryOperator & Serializable) (x, y) -> x + y;
    DoubleAccumulator a = new DoubleAccumulator(plus, 13.9d);
    a.accumulate(17.5d);
    DoubleAccumulator result = echo(a);
    if (result.get() != a.get())
        throw new RuntimeException("Unexpected value");
    a.reset();
    result.reset();
    if (result.get() != a.get())
        throw new RuntimeException("Unexpected value after reset");

    checkSerialClassName(a, "java.util.concurrent.atomic.DoubleAccumulator$SerializationProxy");
}
 
Example 5
Source File: Serial.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
static void testDoubleAccumulator() {
    DoubleBinaryOperator plus = (DoubleBinaryOperator & Serializable) (x, y) -> x + y;
    DoubleAccumulator a = new DoubleAccumulator(plus, 13.9d);
    a.accumulate(17.5d);
    DoubleAccumulator result = echo(a);
    if (result.get() != a.get())
        throw new RuntimeException("Unexpected value");
    a.reset();
    result.reset();
    if (result.get() != a.get())
        throw new RuntimeException("Unexpected value after reset");

    checkSerialClassName(a, "java.util.concurrent.atomic.DoubleAccumulator$SerializationProxy");
}
 
Example 6
Source File: Serial.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
static void testDoubleAccumulator() {
    DoubleBinaryOperator plus = (DoubleBinaryOperator & Serializable) (x, y) -> x + y;
    DoubleAccumulator a = new DoubleAccumulator(plus, 13.9d);
    a.accumulate(17.5d);
    DoubleAccumulator result = echo(a);
    if (result.get() != a.get())
        throw new RuntimeException("Unexpected value");
    a.reset();
    result.reset();
    if (result.get() != a.get())
        throw new RuntimeException("Unexpected value after reset");

    checkSerialClassName(a, "java.util.concurrent.atomic.DoubleAccumulator$SerializationProxy");
}
 
Example 7
Source File: Serial.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
static void testDoubleAccumulator() {
    DoubleBinaryOperator plus = (DoubleBinaryOperator & Serializable) (x, y) -> x + y;
    DoubleAccumulator a = new DoubleAccumulator(plus, 13.9d);
    a.accumulate(17.5d);
    DoubleAccumulator result = echo(a);
    if (result.get() != a.get())
        throw new RuntimeException("Unexpected value");
    a.reset();
    result.reset();
    if (result.get() != a.get())
        throw new RuntimeException("Unexpected value after reset");

    checkSerialClassName(a, "java.util.concurrent.atomic.DoubleAccumulator$SerializationProxy");
}
 
Example 8
Source File: DoubleAccumulatorTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * reset() causes subsequent get() to return zero
 */
public void testReset() {
    DoubleAccumulator ai = new DoubleAccumulator(Double::max, 0.0);
    ai.accumulate(2.0);
    assertEquals(2.0, ai.get());
    ai.reset();
    assertEquals(0.0, ai.get());
}
 
Example 9
Source File: Serial.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
static void testDoubleAccumulator() {
    DoubleBinaryOperator plus = (DoubleBinaryOperator & Serializable) (x, y) -> x + y;
    DoubleAccumulator a = new DoubleAccumulator(plus, 13.9d);
    a.accumulate(17.5d);
    DoubleAccumulator result = echo(a);
    if (result.get() != a.get())
        throw new RuntimeException("Unexpected value");
    a.reset();
    result.reset();
    if (result.get() != a.get())
        throw new RuntimeException("Unexpected value after reset");

    checkSerialClassName(a, "java.util.concurrent.atomic.DoubleAccumulator$SerializationProxy");
}
 
Example 10
Source File: Serial.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
static void testDoubleAccumulator() {
    DoubleBinaryOperator plus = (DoubleBinaryOperator & Serializable) (x, y) -> x + y;
    DoubleAccumulator a = new DoubleAccumulator(plus, 13.9d);
    a.accumulate(17.5d);
    DoubleAccumulator result = echo(a);
    if (result.get() != a.get())
        throw new RuntimeException("Unexpected value");
    a.reset();
    result.reset();
    if (result.get() != a.get())
        throw new RuntimeException("Unexpected value after reset");

    checkSerialClassName(a, "java.util.concurrent.atomic.DoubleAccumulator$SerializationProxy");
}
 
Example 11
Source File: Serial.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
static void testDoubleAccumulator() {
    DoubleBinaryOperator plus = (DoubleBinaryOperator & Serializable) (x, y) -> x + y;
    DoubleAccumulator a = new DoubleAccumulator(plus, 13.9d);
    a.accumulate(17.5d);
    DoubleAccumulator result = echo(a);
    if (result.get() != a.get())
        throw new RuntimeException("Unexpected value");
    a.reset();
    result.reset();
    if (result.get() != a.get())
        throw new RuntimeException("Unexpected value after reset");

    checkSerialClassName(a, "java.util.concurrent.atomic.DoubleAccumulator$SerializationProxy");
}
 
Example 12
Source File: Serial.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
static void testDoubleAccumulator() {
    DoubleBinaryOperator plus = (DoubleBinaryOperator & Serializable) (x, y) -> x + y;
    DoubleAccumulator a = new DoubleAccumulator(plus, 13.9d);
    a.accumulate(17.5d);
    DoubleAccumulator result = echo(a);
    if (result.get() != a.get())
        throw new RuntimeException("Unexpected value");
    a.reset();
    result.reset();
    if (result.get() != a.get())
        throw new RuntimeException("Unexpected value after reset");

    checkSerialClassName(a, "java.util.concurrent.atomic.DoubleAccumulator$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 testDoubleAccumulator() {
    DoubleBinaryOperator plus = (DoubleBinaryOperator & Serializable) (x, y) -> x + y;
    DoubleAccumulator a = new DoubleAccumulator(plus, 13.9d);
    a.accumulate(17.5d);
    DoubleAccumulator result = echo(a);
    if (result.get() != a.get())
        throw new RuntimeException("Unexpected value");
    a.reset();
    result.reset();
    if (result.get() != a.get())
        throw new RuntimeException("Unexpected value after reset");

    checkSerialClassName(a, "java.util.concurrent.atomic.DoubleAccumulator$SerializationProxy");
}
 
Example 14
Source File: Serial.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
static void testDoubleAccumulator() {
    DoubleBinaryOperator plus = (DoubleBinaryOperator & Serializable) (x, y) -> x + y;
    DoubleAccumulator a = new DoubleAccumulator(plus, 13.9d);
    a.accumulate(17.5d);
    DoubleAccumulator result = echo(a);
    if (result.get() != a.get())
        throw new RuntimeException("Unexpected value");
    a.reset();
    result.reset();
    if (result.get() != a.get())
        throw new RuntimeException("Unexpected value after reset");

    checkSerialClassName(a, "java.util.concurrent.atomic.DoubleAccumulator$SerializationProxy");
}
 
Example 15
Source File: Serial.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
static void testDoubleAccumulator() {
    DoubleBinaryOperator plus = (DoubleBinaryOperator & Serializable) (x, y) -> x + y;
    DoubleAccumulator a = new DoubleAccumulator(plus, 13.9d);
    a.accumulate(17.5d);
    DoubleAccumulator result = echo(a);
    if (result.get() != a.get())
        throw new RuntimeException("Unexpected value");
    a.reset();
    result.reset();
    if (result.get() != a.get())
        throw new RuntimeException("Unexpected value after reset");

    checkSerialClassName(a, "java.util.concurrent.atomic.DoubleAccumulator$SerializationProxy");
}
 
Example 16
Source File: DoubleAccumulatorTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * reset() causes subsequent get() to return zero
 */
public void testReset() {
    DoubleAccumulator ai = new DoubleAccumulator(Double::max, 0.0);
    ai.accumulate(2.0);
    assertEquals(2.0, ai.get());
    ai.reset();
    assertEquals(0.0, ai.get());
}