Skip to content

Commit

Permalink
Adds prefab values for (Long|Double)(Adder|Accumulator)
Browse files Browse the repository at this point in the history
  • Loading branch information
jqno committed May 31, 2023
1 parent 000c606 commit 7a2799f
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,29 @@ private void addAtomicClasses() {
);
}
);

DoubleAdder redDoubleAdder = new DoubleAdder();
DoubleAdder blueDoubleAdder = new DoubleAdder();
addValues(DoubleAdder.class, redDoubleAdder, blueDoubleAdder, redDoubleAdder);
DoubleAccumulator redDoubleAccumulator = new DoubleAccumulator((a, b) -> a + b, 0.0);
DoubleAccumulator blueDoubleAccumulator = new DoubleAccumulator((a, b) -> a * b, 1.0);
addValues(
DoubleAccumulator.class,
redDoubleAccumulator,
blueDoubleAccumulator,
redDoubleAccumulator
);
LongAdder redLongAdder = new LongAdder();
LongAdder blueLongAdder = new LongAdder();
addValues(LongAdder.class, redLongAdder, blueLongAdder, redLongAdder);
LongAccumulator redLongAccumulator = new LongAccumulator((a, b) -> a + b, 0);
LongAccumulator blueLongAccumulator = new LongAccumulator((a, b) -> a * b, 1);
addValues(
LongAccumulator.class,
redLongAccumulator,
blueLongAccumulator,
redLongAccumulator
);
}

private void addAncientJavaApiClasses() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@
import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.atomic.AtomicReferenceArray;
import java.util.concurrent.atomic.AtomicStampedReference;
import java.util.concurrent.atomic.DoubleAccumulator;
import java.util.concurrent.atomic.DoubleAdder;
import java.util.concurrent.atomic.LongAccumulator;
import java.util.concurrent.atomic.LongAdder;
import java.util.concurrent.locks.StampedLock;
import java.util.function.Supplier;
import java.util.regex.Pattern;
Expand Down Expand Up @@ -742,6 +746,10 @@ static final class AtomicClassesContainer {
private final AtomicReference<?> atomicReference;
private final AtomicReferenceArray<?> atomicReferenceArray;
private final AtomicStampedReference<?> atomicStampedReference;
private final DoubleAdder doubleAdder;
private final DoubleAccumulator doubleAccumulator;
private final LongAdder longAdder;
private final LongAccumulator longAccumulator;

public AtomicClassesContainer(
AtomicBoolean atomicBoolean,
Expand All @@ -752,7 +760,11 @@ public AtomicClassesContainer(
AtomicMarkableReference<?> atomicMarkableReference,
AtomicReference<?> atomicReference,
AtomicReferenceArray<?> atomicReferenceArray,
AtomicStampedReference<?> atomicStampedReference
AtomicStampedReference<?> atomicStampedReference,
DoubleAdder doubleAdder,
DoubleAccumulator doubleAccumulator,
LongAdder longAdder,
LongAccumulator longAccumulator
) {
this.atomicBoolean = atomicBoolean;
this.atomicInteger = atomicInteger;
Expand All @@ -763,6 +775,10 @@ public AtomicClassesContainer(
this.atomicReference = atomicReference;
this.atomicReferenceArray = atomicReferenceArray;
this.atomicStampedReference = atomicStampedReference;
this.doubleAdder = doubleAdder;
this.doubleAccumulator = doubleAccumulator;
this.longAdder = longAdder;
this.longAccumulator = longAccumulator;
}

@Override
Expand Down

0 comments on commit 7a2799f

Please sign in to comment.