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

changed algorithm order;

filtered stages visiting at runtime
parent c295dc59
No related branches found
No related tags found
No related merge requests found
......@@ -5,7 +5,7 @@ import java.util.Set;
import teetime.framework.pipe.IPipe;
public class A2ThreadableStageCollector implements IPipeVisitor {
public class A1ThreadableStageCollector implements IPipeVisitor {
private final Set<Stage> threadableStages = new HashSet<Stage>();
private final Set<IPipe<?>> visitedPipes = new HashSet<IPipe<?>>();
......
......@@ -7,13 +7,13 @@ import teetime.framework.pipe.IPipe;
import com.carrotsearch.hppc.ObjectIntHashMap;
import com.carrotsearch.hppc.ObjectIntMap;
public class A3InvalidThreadAssignmentCheck {
public class A2InvalidThreadAssignmentCheck {
private static final int DEFAULT_COLOR = 0;
private final Set<Stage> threadableStages;
public A3InvalidThreadAssignmentCheck(final Set<Stage> threadableStages) {
public A2InvalidThreadAssignmentCheck(final Set<Stage> threadableStages) {
this.threadableStages = threadableStages;
}
......@@ -28,7 +28,6 @@ public class A3InvalidThreadAssignmentCheck {
ThreadPainter threadPainter = new ThreadPainter(colors, color, threadableStages);
Traverser traverser = new Traverser(threadPainter);
traverser.traverse(threadableStage);
// threadPainter.check(threadableStage);
}
}
......@@ -45,19 +44,6 @@ public class A3InvalidThreadAssignmentCheck {
this.threadableStages = threadableStages;
}
// TODO consider to implement it as IPipeVisitor(FORWARD)
// public void check(final Stage stage) {
// for (OutputPort<?> outputPort : stage.getOutputPorts()) {
// if (outputPort.pipe != DummyPipe.INSTANCE) {
// Stage nextStage = checkPipe(outputPort.pipe);
// if (nextStage != null) {
// check(nextStage);
// }
// }
// }
// }
@Override
public VisitorBehavior visit(final IPipe<?> pipe) {
Stage targetStage = pipe.getTargetPort().getOwningStage();
......
......@@ -10,7 +10,7 @@ import teetime.framework.pipe.SingleElementPipeFactory;
import teetime.framework.pipe.SpScPipeFactory;
import teetime.framework.pipe.UnboundedSpScPipeFactory;
public class A1PipeInstantiation implements IPipeVisitor {
public class A3PipeInstantiation implements IPipeVisitor {
private static final IPipeFactory interBoundedThreadPipeFactory = new SpScPipeFactory();
private static final IPipeFactory interUnboundedThreadPipeFactory = new UnboundedSpScPipeFactory();
......
......@@ -17,6 +17,7 @@ package teetime.framework;
public enum StageState {
/** First state of a stage */
CREATED,
INITIALIZED,
VALIDATING, VALIDATED,
......
......@@ -45,12 +45,8 @@ class ThreadService extends AbstractService<ThreadService> {
// TODO visit(port) only
// TODO use decorator pattern to combine all analyzes so that only one traverser pass is necessary
IPortVisitor portVisitor = new A0UnconnectedPort();
IPipeVisitor pipeVisitor = new A1PipeInstantiation();
Traverser traversor = new Traverser(portVisitor, pipeVisitor, Direction.BOTH);
traversor.traverse(startStage);
A2ThreadableStageCollector stageCollector = new A2ThreadableStageCollector();
traversor = new Traverser(stageCollector, Direction.BOTH);
A1ThreadableStageCollector stageCollector = new A1ThreadableStageCollector();
Traverser traversor = new Traverser(portVisitor, stageCollector, Direction.BOTH);
traversor.traverse(startStage);
threadableStages = stageCollector.getThreadableStages();
......@@ -58,9 +54,13 @@ class ThreadService extends AbstractService<ThreadService> {
throw new IllegalStateException("No stage was added using the addThreadableStage(..) method. Add at least one stage.");
}
A3InvalidThreadAssignmentCheck checker = new A3InvalidThreadAssignmentCheck(threadableStages);
A2InvalidThreadAssignmentCheck checker = new A2InvalidThreadAssignmentCheck(threadableStages);
checker.check();
IPipeVisitor pipeVisitor = new A3PipeInstantiation();
traversor = new Traverser(pipeVisitor, Direction.BOTH);
traversor.traverse(startStage);
A4StageAttributeSetter attributeSetter = new A4StageAttributeSetter(configuration, threadableStages);
attributeSetter.setAttributes();
......
......@@ -65,7 +65,8 @@ public class Traverser {
}
public void traverse(final Stage stage) {
if (!visitedStages.add(stage)) {
if (!visitedStages.add(stage) || stage.getCurrentState() != StageState.CREATED) {
// do not visit (1) an already visited stage and (2) a stage that currently run (runtime visiting)
return;
}
......
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