Skip to content
Snippets Groups Projects
Commit ba4f287d authored by Nelson Tavares de Sousa's avatar Nelson Tavares de Sousa
Browse files

added first draft of better pipe instantiation

parent cc4f9c46
No related branches found
No related tags found
No related merge requests found
......@@ -17,8 +17,10 @@ package teetime.framework;
import java.lang.Thread.UncaughtExceptionHandler;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentLinkedQueue;
......@@ -189,7 +191,7 @@ public final class Analysis<T extends AnalysisConfiguration> implements Uncaught
if (connection.getCapacity() != 0) {
interBoundedThreadPipeFactory.create(connection.getSourcePort(), connection.getTargetPort(), connection.getCapacity());
} else {
interUnboundedThreadPipeFactory.create(connection.getSourcePort(), connection.getTargetPort(), connection.getCapacity());
interUnboundedThreadPipeFactory.create(connection.getSourcePort(), connection.getTargetPort(), 4);
}
} else {
intraThreadPipeFactory.create(connection.getSourcePort(), connection.getTargetPort());
......@@ -197,6 +199,33 @@ public final class Analysis<T extends AnalysisConfiguration> implements Uncaught
}
}
private void prototypeInstantiatePipes() {
Integer i = new Integer(0);
Map<Stage, Integer> colors = new HashMap<Stage, Integer>();
Set<Stage> threadableStageJobs = configuration.getThreadableStageJobs();
for (Stage threadableStage : threadableStageJobs) {
colors.put(threadableStage, i); // Markiere den threadHead
for (Connection connection : configuration.getConnections()) {
// Die Connection gehört zu der Stage
if (connection.getSourcePort().getOwningStage() == threadableStage) {
Stage targetStage = connection.getTargetPort().getOwningStage();
if (threadableStageJobs.contains(targetStage) /* colors.get(targetStage) == i */) { // Auch auf Farbe prüfen
if (connection.getCapacity() != 0) {
interBoundedThreadPipeFactory.create(connection.getSourcePort(), connection.getTargetPort(), connection.getCapacity());
} else {
interUnboundedThreadPipeFactory.create(connection.getSourcePort(), connection.getTargetPort(), 4);
}
} else {
intraThreadPipeFactory.create(connection.getSourcePort(), connection.getTargetPort());
colors.put(targetStage, i);
}
// configuration.getConnections().remove(connection); remove connection to increase performance
}
}
i++;
}
}
private Thread createThread(final AbstractRunnableStage runnable, final String name) {
final Thread thread = new Thread(runnable);
thread.setUncaughtExceptionHandler(this);
......
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