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

set DummyPipe as default

parent d107f574
No related branches found
No related tags found
No related merge requests found
/**
* Copyright (C) 2015 Christian Wulf, Nelson Tavares de Sousa (http://christianwulf.github.io/teetime)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package teetime.framework;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import teetime.framework.Traverser.VisitorBehavior;
import teetime.framework.pipe.DummyPipe;
/**
* Connects unconnected ports to a dummy pipe
*/
class A0UnconnectedPort implements ITraverserVisitor {
private static final Logger LOGGER = LoggerFactory.getLogger(A0UnconnectedPort.class);
@Override
public VisitorBehavior visit(final Stage stage) {
return VisitorBehavior.CONTINUE;
}
@Override
public VisitorBehavior visit(final AbstractPort<?> port) {
if (port.getPipe() == null) {
if (LOGGER.isInfoEnabled()) {
LOGGER.info("Unconnected output port: " + port + ". Connecting with a dummy output port.");
}
port.setPipe(DummyPipe.INSTANCE);
return VisitorBehavior.STOP;
}
return VisitorBehavior.CONTINUE;
}
}
......@@ -15,6 +15,7 @@
*/
package teetime.framework;
import teetime.framework.pipe.DummyPipe;
import teetime.framework.signal.ISignal;
import teetime.framework.signal.TerminatingSignal;
......@@ -31,6 +32,7 @@ public class OutputPort<T> extends AbstractPort<T> {
OutputPort(final Class<T> type, final Stage owningStage, final String portName) {
super(type, owningStage, portName);
setPipe(DummyPipe.INSTANCE);
}
/**
......
......@@ -78,12 +78,9 @@ class ThreadService extends AbstractService<ThreadService> {
}
// TODO use decorator pattern to combine all analyzes so that only one traverser pass is necessary
A0UnconnectedPort portVisitor = new A0UnconnectedPort();
Traverser traversor = new Traverser(portVisitor, Direction.BOTH);
traversor.traverse(startStage);
A1ThreadableStageCollector stageCollector = new A1ThreadableStageCollector();
traversor = new Traverser(stageCollector, Direction.BOTH);
Traverser traversor = new Traverser(stageCollector, Direction.BOTH);
traversor.traverse(startStage);
Set<Stage> newThreadableStages = stageCollector.getThreadableStages();
......
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