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

refactoring

parent 63fb9fec
No related branches found
No related tags found
No related merge requests found
......@@ -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()) {
......
......@@ -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);
}
}
......@@ -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");
}
......
......@@ -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);
......
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