From 0fbfb78acb2147f077eec6bae9170e4c60b1e123 Mon Sep 17 00:00:00 2001 From: Nelson Tavares de Sousa <stu103017@mail.uni-kiel.de> Date: Tue, 16 Jun 2015 15:30:26 +0200 Subject: [PATCH] refactoring --- src/main/java/teetime/framework/Analysis.java | 4 ++-- .../framework/AnalysisConfiguration.java | 3 +-- .../framework/AnalysisInstantiation.java | 18 ++++++++++++------ .../framework/pipe/InstantiationPipe.java | 6 +++--- 4 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/main/java/teetime/framework/Analysis.java b/src/main/java/teetime/framework/Analysis.java index ea917227..a8fc0514 100644 --- a/src/main/java/teetime/framework/Analysis.java +++ b/src/main/java/teetime/framework/Analysis.java @@ -118,8 +118,8 @@ public final class Analysis<T extends AnalysisConfiguration> implements Uncaught * */ private final void init() { - - AnalysisInstantiation.instantiatePipes(configuration); + AnalysisInstantiation analysisInstantiation = new AnalysisInstantiation(configuration); + analysisInstantiation.instantiatePipes(); final Set<Stage> threadableStageJobs = this.configuration.getThreadableStages(); if (threadableStageJobs.isEmpty()) { diff --git a/src/main/java/teetime/framework/AnalysisConfiguration.java b/src/main/java/teetime/framework/AnalysisConfiguration.java index f8987044..fc8c16c8 100644 --- a/src/main/java/teetime/framework/AnalysisConfiguration.java +++ b/src/main/java/teetime/framework/AnalysisConfiguration.java @@ -176,8 +176,7 @@ public abstract class AnalysisConfiguration { * the pipe is set to this capacity, if the value is greater than 0. If it is 0, than the pipe is unbounded, thus growing of the pipe is enabled. */ protected final <T> void connectPorts(final OutputPort<? extends T> sourcePort, final InputPort<T> targetPort, final int capacity) { - new InstantiationPipe<T>(sourcePort, targetPort, capacity); - // connections.add(new Connection<T>(sourcePort, targetPort, capacity)); + new InstantiationPipe(sourcePort, targetPort, capacity); } } diff --git a/src/main/java/teetime/framework/AnalysisInstantiation.java b/src/main/java/teetime/framework/AnalysisInstantiation.java index e659e4e7..d1283e22 100644 --- a/src/main/java/teetime/framework/AnalysisInstantiation.java +++ b/src/main/java/teetime/framework/AnalysisInstantiation.java @@ -17,12 +17,18 @@ class AnalysisInstantiation { private static final Logger LOGGER = LoggerFactory.getLogger(AnalysisInstantiation.class); - private static final IPipeFactory interBoundedThreadPipeFactory = new SpScPipeFactory(); - private static final IPipeFactory interUnboundedThreadPipeFactory = new UnboundedSpScPipeFactory(); - private static final IPipeFactory intraThreadPipeFactory = new SingleElementPipeFactory(); + private final IPipeFactory interBoundedThreadPipeFactory = new SpScPipeFactory(); + private final IPipeFactory interUnboundedThreadPipeFactory = new UnboundedSpScPipeFactory(); + private final IPipeFactory intraThreadPipeFactory = new SingleElementPipeFactory(); + + private final AnalysisConfiguration configuration; + + public AnalysisInstantiation(final AnalysisConfiguration configuration) { + this.configuration = configuration; + } @SuppressWarnings("rawtypes") - static Integer colorAndConnectStages(final Integer i, final Map<Stage, Integer> colors, final Stage threadableStage, final AnalysisConfiguration configuration) { + Integer colorAndConnectStages(final Integer i, final Map<Stage, Integer> colors, final Stage threadableStage, final AnalysisConfiguration configuration) { Integer createdConnections = new Integer(0); Set<Stage> threadableStageJobs = configuration.getThreadableStages(); for (OutputPort outputPort : threadableStage.getOutputPorts()) { @@ -58,7 +64,7 @@ class AnalysisInstantiation { return createdConnections; } - static void instantiatePipes(final AnalysisConfiguration configuration) { + void instantiatePipes() { Integer i = new Integer(0); Map<Stage, Integer> colors = new HashMap<Stage, Integer>(); Set<Stage> threadableStageJobs = configuration.getThreadableStages(); @@ -66,7 +72,7 @@ class AnalysisInstantiation { for (Stage threadableStage : threadableStageJobs) { i++; colors.put(threadableStage, i); - createdConnections = AnalysisInstantiation.colorAndConnectStages(i, colors, threadableStage, configuration); + createdConnections = colorAndConnectStages(i, colors, threadableStage, configuration); } LOGGER.debug("Created " + createdConnections + "connections"); } diff --git a/src/main/java/teetime/framework/pipe/InstantiationPipe.java b/src/main/java/teetime/framework/pipe/InstantiationPipe.java index 799ed324..702de988 100644 --- a/src/main/java/teetime/framework/pipe/InstantiationPipe.java +++ b/src/main/java/teetime/framework/pipe/InstantiationPipe.java @@ -19,12 +19,12 @@ import teetime.framework.InputPort; import teetime.framework.OutputPort; import teetime.framework.signal.ISignal; -public class InstantiationPipe<T> implements IPipe { +public class InstantiationPipe implements IPipe { - private final InputPort<T> target; + private final InputPort target; private final int capacity; - public InstantiationPipe(final OutputPort<? extends T> sourcePort, final InputPort<T> targetPort, final int capacity) { + public <T> InstantiationPipe(final OutputPort<? extends T> sourcePort, final InputPort<T> targetPort, final int capacity) { this.target = targetPort; this.capacity = capacity; sourcePort.setPipe(this); -- GitLab