diff --git a/src/main/java/teetime/framework/pipe/IPipeFactory.java b/src/main/java/teetime/framework/pipe/IPipeFactory.java index b3fde09beb90469b2d47fcb22967a72f6451c494..48627dbac5369b2ec6d7fa7cb1bf849f333c1955 100644 --- a/src/main/java/teetime/framework/pipe/IPipeFactory.java +++ b/src/main/java/teetime/framework/pipe/IPipeFactory.java @@ -10,6 +10,13 @@ public interface IPipeFactory { @Deprecated IPipe create(int capacity); + /** + * with the default capacity + * + * @param sourcePort + * @param targetPort + * @return + */ <T> IPipe create(OutputPort<? extends T> sourcePort, InputPort<T> targetPort); <T> IPipe create(OutputPort<? extends T> sourcePort, InputPort<T> targetPort, int capacity); diff --git a/src/main/java/teetime/framework/pipe/PipeFactory.java b/src/main/java/teetime/framework/pipe/PipeFactory.java index 57de4c11117a63d8a8317e92f9a4c75e3f67ab9c..3e1cc675922c4b19e140c51d09add32758b1171c 100644 --- a/src/main/java/teetime/framework/pipe/PipeFactory.java +++ b/src/main/java/teetime/framework/pipe/PipeFactory.java @@ -43,17 +43,7 @@ public class PipeFactory { } } - /** - * Creates a new FIFO-ordered, growable pipe with an initial capacity of 1. <br> - * <i>This method is suitable for most situations.</i> - * - * @param tc - * @return - */ - public IPipe create(final ThreadCommunication tc) { - return this.create(tc, PipeOrdering.QUEUE_BASED, true, 1); - } - + @Deprecated public IPipe create(final ThreadCommunication tc, final PipeOrdering ordering, final boolean growable, final int capacity) { IPipeFactory pipeFactory = getPipeFactory(tc, ordering, growable); return pipeFactory.create(capacity); diff --git a/src/performancetest/java/teetime/examples/experiment14/MethodCallThroughputAnalysis14.java b/src/performancetest/java/teetime/examples/experiment14/MethodCallThroughputAnalysis14.java index f2bfdf3521d0483180461988cbe21a848ca83d7c..3b32e2bdadd7c333e92dda19187ec7e673eb8e3c 100644 --- a/src/performancetest/java/teetime/examples/experiment14/MethodCallThroughputAnalysis14.java +++ b/src/performancetest/java/teetime/examples/experiment14/MethodCallThroughputAnalysis14.java @@ -21,8 +21,9 @@ import teetime.framework.HeadPipeline; import teetime.framework.HeadStage; import teetime.framework.OldAnalysis; import teetime.framework.RunnableStage; -import teetime.framework.pipe.IPipe; +import teetime.framework.pipe.IPipeFactory; import teetime.framework.pipe.PipeFactory; +import teetime.framework.pipe.PipeFactory.PipeOrdering; import teetime.framework.pipe.PipeFactory.ThreadCommunication; import teetime.stage.CollectorSink; import teetime.stage.NoopFilter; @@ -74,18 +75,15 @@ public class MethodCallThroughputAnalysis14 extends OldAnalysis { pipeline.setFirstStage(objectProducer); pipeline.setLastStage(collectorSink); - IPipe pipe = this.pipeFactory.create(ThreadCommunication.INTRA); - pipe.connectPorts(objectProducer.getOutputPort(), startTimestampFilter.getInputPort()); - pipe = this.pipeFactory.create(ThreadCommunication.INTRA); - pipe.connectPorts(startTimestampFilter.getOutputPort(), noopFilters[0].getInputPort()); + IPipeFactory factory = this.pipeFactory.getPipeFactory(ThreadCommunication.INTRA, PipeOrdering.QUEUE_BASED, true); + + factory.create(objectProducer.getOutputPort(), startTimestampFilter.getInputPort()); + factory.create(startTimestampFilter.getOutputPort(), noopFilters[0].getInputPort()); for (int i = 0; i < noopFilters.length - 1; i++) { - pipe = this.pipeFactory.create(ThreadCommunication.INTRA); - pipe.connectPorts(noopFilters[i].getOutputPort(), noopFilters[i + 1].getInputPort()); + factory.create(noopFilters[i].getOutputPort(), noopFilters[i + 1].getInputPort()); } - pipe = this.pipeFactory.create(ThreadCommunication.INTRA); - pipe.connectPorts(noopFilters[noopFilters.length - 1].getOutputPort(), stopTimestampFilter.getInputPort()); - pipe = this.pipeFactory.create(ThreadCommunication.INTRA); - pipe.connectPorts(stopTimestampFilter.getOutputPort(), collectorSink.getInputPort()); + factory.create(noopFilters[noopFilters.length - 1].getOutputPort(), stopTimestampFilter.getInputPort()); + factory.create(stopTimestampFilter.getOutputPort(), collectorSink.getInputPort()); return pipeline; } diff --git a/src/performancetest/java/teetime/examples/loopStage/LoopStageAnalysisConfiguration.java b/src/performancetest/java/teetime/examples/loopStage/LoopStageAnalysisConfiguration.java index 6f577b4143ff364bb961910ca0d243d451a5524e..a366e72dac394fa21e0b82dc457d664f1c2bf2f3 100644 --- a/src/performancetest/java/teetime/examples/loopStage/LoopStageAnalysisConfiguration.java +++ b/src/performancetest/java/teetime/examples/loopStage/LoopStageAnalysisConfiguration.java @@ -1,16 +1,20 @@ package teetime.examples.loopStage; import teetime.framework.AnalysisConfiguration; +import teetime.framework.pipe.IPipeFactory; import teetime.framework.pipe.PipeFactory; +import teetime.framework.pipe.PipeFactory.PipeOrdering; import teetime.framework.pipe.PipeFactory.ThreadCommunication; public class LoopStageAnalysisConfiguration extends AnalysisConfiguration { + private final PipeFactory pipeFactory = PipeFactory.INSTANCE; + public LoopStageAnalysisConfiguration() { Countdown countdown = new Countdown(10); - PipeFactory.INSTANCE.create(ThreadCommunication.INTRA) - .connectPorts(countdown.getNewCountdownOutputPort(), countdown.getCountdownInputPort()); + IPipeFactory factory = this.pipeFactory.getPipeFactory(ThreadCommunication.INTRA, PipeOrdering.QUEUE_BASED, true); + factory.create(countdown.getNewCountdownOutputPort(), countdown.getCountdownInputPort()); this.getFiniteProducerStages().add(countdown); } diff --git a/src/performancetest/java/teetime/runtime/typeCheck/ConnectionTypeTest.java b/src/performancetest/java/teetime/runtime/typeCheck/ConnectionTypeTest.java index 827ff18feff3c598c829246fafcb4d2642b81ec8..3caa3cf553562ed30dc35d3da1c9450cfc752e6f 100644 --- a/src/performancetest/java/teetime/runtime/typeCheck/ConnectionTypeTest.java +++ b/src/performancetest/java/teetime/runtime/typeCheck/ConnectionTypeTest.java @@ -8,8 +8,9 @@ import java.lang.reflect.InvocationTargetException; import org.junit.Test; -import teetime.framework.pipe.IPipe; +import teetime.framework.pipe.IPipeFactory; import teetime.framework.pipe.PipeFactory; +import teetime.framework.pipe.PipeFactory.PipeOrdering; import teetime.framework.pipe.PipeFactory.ThreadCommunication; import teetime.stage.ObjectProducer; import teetime.stage.PortTypeConfiguration; @@ -46,12 +47,10 @@ public class ConnectionTypeTest { StopTimestampFilter stopTimestampFilter = StopTimestampFilter.class.newInstance(); Sink sink = Sink.class.newInstance(); - IPipe pipe = this.pipeFactory.create(ThreadCommunication.INTRA); - pipe.connectPorts(objectProducer.getOutputPort(), startTimestampFilter.getInputPort()); - pipe = this.pipeFactory.create(ThreadCommunication.INTRA); - pipe.connectPorts(startTimestampFilter.getOutputPort(), stopTimestampFilter.getInputPort()); - pipe = this.pipeFactory.create(ThreadCommunication.INTRA); - pipe.connectPorts(stopTimestampFilter.getOutputPort(), sink.getInputPort()); + IPipeFactory factory = this.pipeFactory.getPipeFactory(ThreadCommunication.INTRA, PipeOrdering.QUEUE_BASED, true); + factory.create(objectProducer.getOutputPort(), startTimestampFilter.getInputPort()); + factory.create(startTimestampFilter.getOutputPort(), stopTimestampFilter.getInputPort()); + factory.create(stopTimestampFilter.getOutputPort(), sink.getInputPort()); // TypeVariable<Class<ObjectProducer>>[] objectProducerTypeParameters = ObjectProducer.class.getTypeParameters(); // for (TypeVariable<Class<ObjectProducer>> typeVariable : objectProducerTypeParameters) {