Skip to content
Snippets Groups Projects
Commit 013c1c14 authored by Christian Wulf's avatar Christian Wulf
Browse files

added unfinished draft for a reduction variable abstraction

parent 2194c03a
No related branches found
No related tags found
No related merge requests found
...@@ -24,4 +24,23 @@ public class Counter<T> extends AbstractConsumerStage<T> { ...@@ -24,4 +24,23 @@ public class Counter<T> extends AbstractConsumerStage<T> {
public OutputPort<T> getOutputPort() { public OutputPort<T> getOutputPort() {
return this.outputPort; return this.outputPort;
} }
public static final class ThreadLocalCounter {
private final ThreadLocal<Integer> counter = new ThreadLocal<Integer>();
public Integer inc() {
Integer value = counter.get();
Integer newValue = value + 1;
counter.set(newValue);
return newValue;
}
public Integer inc(final Integer rightHandValue) {
Integer value = counter.get();
Integer newValue = value + rightHandValue;
counter.set(newValue);
return newValue;
}
}
} }
wiki @ 0e447457
Subproject commit a93581905ef7b0584d52eae1898148ffa6201a31 Subproject commit 0e4474577e1f49bc96e734c286b2d9e0363895e8
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment