From ce590e19ecb838e12b8915d776b685128f3fd830 Mon Sep 17 00:00:00 2001
From: Christian Wulf <chw@informatik.uni-kiel.de>
Date: Sat, 14 Jun 2014 17:10:43 +0200
Subject: [PATCH] removed runnables due to performance decrease

---
 .../throughput/methodcall/AbstractStage.java  | 38 +++++++------------
 .../throughput/methodcall/ObjectProducer.java |  2 -
 2 files changed, 13 insertions(+), 27 deletions(-)

diff --git a/src/test/java/teetime/examples/throughput/methodcall/AbstractStage.java b/src/test/java/teetime/examples/throughput/methodcall/AbstractStage.java
index 9b8712eb..9814f30f 100644
--- a/src/test/java/teetime/examples/throughput/methodcall/AbstractStage.java
+++ b/src/test/java/teetime/examples/throughput/methodcall/AbstractStage.java
@@ -2,32 +2,8 @@ package teetime.examples.throughput.methodcall;
 
 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 OutputPort<O> outputPort = new OutputPort<O>();
-	protected Runnable endSignalCheck = this.inputPortIsUsed;
 
 	@Override
 	public InputPort<I> getInputPort() {
@@ -41,8 +17,20 @@ public abstract class AbstractStage<I, O> implements Stage<I, O> {
 
 	@Override
 	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 O[] execute4(I[] elements, int size);
 }
diff --git a/src/test/java/teetime/examples/throughput/methodcall/ObjectProducer.java b/src/test/java/teetime/examples/throughput/methodcall/ObjectProducer.java
index bcb19d0f..0e7b0d77 100644
--- a/src/test/java/teetime/examples/throughput/methodcall/ObjectProducer.java
+++ b/src/test/java/teetime/examples/throughput/methodcall/ObjectProducer.java
@@ -33,8 +33,6 @@ public class ObjectProducer<T> extends AbstractStage<Void, T> {
 	public ObjectProducer(final long numInputObjects, final Callable<T> inputObjectCreator) {
 		this.numInputObjects = numInputObjects;
 		this.inputObjectCreator = inputObjectCreator;
-
-		this.endSignalCheck = this.inputPortIsNotUsed;
 	}
 
 	public T execute() {
-- 
GitLab