From 5e20b56716da351dbbe8c39f6378b0620301dddf Mon Sep 17 00:00:00 2001
From: Christian Wulf <chw@informatik.uni-kiel.de>
Date: Thu, 26 Jun 2014 12:17:05 +0200
Subject: [PATCH] added cache tasks

---
 .../framework/core/AbstractStage.java         | 10 ++------
 .../framework/core/Pipeline.java              | 25 ++-----------------
 2 files changed, 4 insertions(+), 31 deletions(-)

diff --git a/src/main/java/teetime/variant/methodcallWithPorts/framework/core/AbstractStage.java b/src/main/java/teetime/variant/methodcallWithPorts/framework/core/AbstractStage.java
index f54fa344..8c0584ac 100644
--- a/src/main/java/teetime/variant/methodcallWithPorts/framework/core/AbstractStage.java
+++ b/src/main/java/teetime/variant/methodcallWithPorts/framework/core/AbstractStage.java
@@ -13,7 +13,7 @@ public abstract class AbstractStage<I, O> implements StageWithPort<I, O> {
 	/**
 	 * A unique logger instance per stage instance
 	 */
-	protected Log logger;
+	protected final Log logger; // BETTER use SLF4J as interface and logback as impl
 
 	private final InputPort<I> inputPort = new InputPort<I>(this);
 	private final OutputPort<O> outputPort = new OutputPort<O>();
@@ -22,11 +22,6 @@ public abstract class AbstractStage<I, O> implements StageWithPort<I, O> {
 
 	private boolean reschedulable;
 
-	/**
-	 * cached successor for default output port
-	 */
-	private StageWithPort<?, ?> next;
-
 	public AbstractStage() {
 		this.id = UUID.randomUUID().toString(); // the id should only be represented by a UUID, not additionally by the class name
 		this.logger = LogFactory.getLog(this.getClass().getName() + "(" + this.id + ")");
@@ -90,7 +85,7 @@ public abstract class AbstractStage<I, O> implements StageWithPort<I, O> {
 		StageWithPort<?, ?> next = outputPort.getCachedTargetStage();
 
 		do {
-			next.executeWithPorts();
+			next.executeWithPorts(); // PERFORMANCE use the return value as indicator for re-schedulability instead
 		} while (next.isReschedulable());
 	}
 
@@ -108,7 +103,6 @@ public abstract class AbstractStage<I, O> implements StageWithPort<I, O> {
 	@Override
 	public void onStart() {
 		// empty default implementation
-		this.next = (this.outputPort.getPipe() != null) ? this.outputPort.getPipe().getTargetPort().getOwningStage() : null;
 	}
 
 	@Override
diff --git a/src/main/java/teetime/variant/methodcallWithPorts/framework/core/Pipeline.java b/src/main/java/teetime/variant/methodcallWithPorts/framework/core/Pipeline.java
index 04ec7240..596dce3f 100644
--- a/src/main/java/teetime/variant/methodcallWithPorts/framework/core/Pipeline.java
+++ b/src/main/java/teetime/variant/methodcallWithPorts/framework/core/Pipeline.java
@@ -112,27 +112,6 @@ public class Pipeline<I, O> implements StageWithPort<I, O> {
 
 	@Override
 	public void onStart() {
-		// Pipe pipe = new Pipe();
-		// this.outputPort.pipe = pipe;
-		// this.firstStage.getInputPort().pipe = pipe;
-
-		// Pipe pipe = new Pipe();
-		// this.firstStage.getOutputPort().pipe = pipe;
-		// this.intermediateStages.get(0).getInputPort().pipe = pipe;
-		//
-		// for (int i = 0; i < this.intermediateStages.size() - 1; i++) {
-		// Stage left = this.intermediateStages.get(i);
-		// Stage right = this.intermediateStages.get(i + 1);
-		//
-		// pipe = new Pipe();
-		// left.getOutputPort().pipe = pipe;
-		// right.getInputPort().pipe = pipe;
-		// }
-		//
-		// pipe = new Pipe();
-		// this.intermediateStages.get(this.intermediateStages.size() - 1).getOutputPort().pipe = pipe;
-		// this.lastStage.getInputPort().pipe = pipe;
-
 		int size = 1 + this.intermediateStages.size() + 1;
 		this.stages = new StageWithPort[size];
 		this.stages[0] = this.firstStage;
@@ -180,12 +159,12 @@ public class Pipeline<I, O> implements StageWithPort<I, O> {
 
 	@Override
 	public InputPort<I> getInputPort() {
-		return this.firstStage.getInputPort();
+		return this.firstStage.getInputPort(); // CACHE pipeline's input port
 	}
 
 	@Override
 	public OutputPort<O> getOutputPort() {
-		return this.lastStage.getOutputPort();
+		return this.lastStage.getOutputPort(); // CACHE pipeline's output port
 	}
 
 	// TODO remove since it does not increase performances
-- 
GitLab