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

removed runnables due to performance decrease

parent 4ce74fdb
No related branches found
No related tags found
No related merge requests found
...@@ -2,32 +2,8 @@ package teetime.examples.throughput.methodcall; ...@@ -2,32 +2,8 @@ package teetime.examples.throughput.methodcall;
public abstract class AbstractStage<I, O> implements Stage<I, O> { public abstract class AbstractStage<I, O> implements Stage<I, O> {
Runnable inputPortIsUsed = new Runnable() {
@Override
public void run() {
// pass through the end signal
I element = AbstractStage.this.getInputPort().read();
if (element == END_SIGNAL) {
AbstractStage.this.getOutputPort().send((O) END_SIGNAL);
return;
}
AbstractStage.this.execute3();
}
};
Runnable inputPortIsNotUsed = new Runnable() {
@Override
public void run() {
// do not check
AbstractStage.this.execute3();
}
};
private final InputPort<I> inputPort = new InputPort<I>(); private final InputPort<I> inputPort = new InputPort<I>();
private final OutputPort<O> outputPort = new OutputPort<O>(); private final OutputPort<O> outputPort = new OutputPort<O>();
protected Runnable endSignalCheck = this.inputPortIsUsed;
@Override @Override
public InputPort<I> getInputPort() { public InputPort<I> getInputPort() {
...@@ -41,8 +17,20 @@ public abstract class AbstractStage<I, O> implements Stage<I, O> { ...@@ -41,8 +17,20 @@ public abstract class AbstractStage<I, O> implements Stage<I, O> {
@Override @Override
public final void execute2() { public final void execute2() {
this.endSignalCheck.run(); // pass through the end signal
InputPort<I> port = this.getInputPort();
if (port.pipe != null) {
I element = port.read();
if (element == END_SIGNAL) {
this.getOutputPort().send((O) END_SIGNAL);
return;
}
}
this.execute3();
} }
protected abstract void execute3(); protected abstract void execute3();
// protected abstract O[] execute4(I[] elements, int size);
} }
...@@ -33,8 +33,6 @@ public class ObjectProducer<T> extends AbstractStage<Void, T> { ...@@ -33,8 +33,6 @@ public class ObjectProducer<T> extends AbstractStage<Void, T> {
public ObjectProducer(final long numInputObjects, final Callable<T> inputObjectCreator) { public ObjectProducer(final long numInputObjects, final Callable<T> inputObjectCreator) {
this.numInputObjects = numInputObjects; this.numInputObjects = numInputObjects;
this.inputObjectCreator = inputObjectCreator; this.inputObjectCreator = inputObjectCreator;
this.endSignalCheck = this.inputPortIsNotUsed;
} }
public T execute() { public T execute() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment