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

stages without InputPorts are now automatically added to the

threadableStages list
parent 0a67fd7a
No related branches found
No related tags found
No related merge requests found
......@@ -192,6 +192,9 @@ public abstract class AnalysisContext extends Network {
*/
@Override
protected final <T> void connectPorts(final OutputPort<? extends T> sourcePort, final InputPort<T> targetPort, final int capacity) {
if (sourcePort.getOwningStage().getInputPorts().length == 0) {
addThreadableStage(sourcePort.getOwningStage());
}
new InstantiationPipe(sourcePort, targetPort, capacity);
}
......
......@@ -150,4 +150,33 @@ public class AnalysisTest {
}
}
@Test
public void automaticallyAddHeadStages() {
AutomaticallyConfig context = new AutomaticallyConfig();
new Analysis<AnalysisContext>(context).executeBlocking();
assertTrue(context.executed);
}
private class AutomaticallyConfig extends AnalysisContext {
public boolean executed;
public AutomaticallyConfig() {
AutomaticallyAddedStage aas = new AutomaticallyAddedStage();
Sink<Object> sink = new Sink<Object>();
connectPorts(aas.getOutputPort(), sink.getInputPort());
}
private class AutomaticallyAddedStage extends AbstractProducerStage<Object> {
@Override
protected void execute() {
executed = true;
terminate();
}
}
}
}
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