Skip to content
Snippets Groups Projects
Commit 2d77ef46 authored by Christian Wulf's avatar Christian Wulf
Browse files

added constant dummy port

parent 0b2cfade
No related branches found
No related tags found
No related merge requests found
...@@ -12,6 +12,8 @@ import teetime.framework.validation.InvalidPortConnection; ...@@ -12,6 +12,8 @@ import teetime.framework.validation.InvalidPortConnection;
public abstract class AbstractStage extends Stage { public abstract class AbstractStage extends Stage {
private static final IPipe DUMMY_PORT = new DummyPipe();
private final List<InputPort<?>> inputPortList = new ArrayList<InputPort<?>>(); private final List<InputPort<?>> inputPortList = new ArrayList<InputPort<?>>();
private final List<OutputPort<?>> outputPortList = new ArrayList<OutputPort<?>>(); private final List<OutputPort<?>> outputPortList = new ArrayList<OutputPort<?>>();
...@@ -84,6 +86,7 @@ public abstract class AbstractStage extends Stage { ...@@ -84,6 +86,7 @@ public abstract class AbstractStage extends Stage {
} }
public void onStarting() throws Exception { public void onStarting() throws Exception {
this.owningThread = Thread.currentThread();
this.cachedInputPorts = this.inputPortList.toArray(new InputPort<?>[0]); this.cachedInputPorts = this.inputPortList.toArray(new InputPort<?>[0]);
this.cachedOutputPorts = this.outputPortList.toArray(new OutputPort<?>[0]); this.cachedOutputPorts = this.outputPortList.toArray(new OutputPort<?>[0]);
...@@ -97,7 +100,7 @@ public abstract class AbstractStage extends Stage { ...@@ -97,7 +100,7 @@ public abstract class AbstractStage extends Stage {
for (OutputPort<?> outputPort : this.cachedOutputPorts) { for (OutputPort<?> outputPort : this.cachedOutputPorts) {
if (null == outputPort.getPipe()) { // if port is unconnected if (null == outputPort.getPipe()) { // if port is unconnected
this.logger.warn("Unconnected output port: " + outputPort + ". Connecting with a dummy output port."); this.logger.warn("Unconnected output port: " + outputPort + ". Connecting with a dummy output port.");
outputPort.setPipe(new DummyPipe()); outputPort.setPipe(DUMMY_PORT);
} }
} }
} }
......
...@@ -27,7 +27,8 @@ public abstract class Stage { ...@@ -27,7 +27,8 @@ public abstract class Stage {
@SuppressWarnings("PMD.LoggerIsNotStaticFinal") @SuppressWarnings("PMD.LoggerIsNotStaticFinal")
protected final Logger logger; protected final Logger logger;
private Thread owningThread; /** The owning thread of this stage if this stage is directly executed by a {@link RunnableStage}, <code>null</code> otherwise. */
protected Thread owningThread;
protected Stage() { protected Stage() {
this.id = this.createId(); this.id = this.createId();
...@@ -94,11 +95,12 @@ public abstract class Stage { ...@@ -94,11 +95,12 @@ public abstract class Stage {
return owningThread; return owningThread;
} }
public void setOwningThread(final Thread owningThread) { void setOwningThread(final Thread owningThread) {
this.owningThread = owningThread; this.owningThread = owningThread;
} }
protected abstract InputPort<?>[] getInputPorts(); protected abstract InputPort<?>[] getInputPorts();
protected abstract boolean isStarted(); protected abstract boolean isStarted();
} }
...@@ -37,7 +37,7 @@ class ChwHomePerformanceCheck extends AbstractPerformanceCheck { ...@@ -37,7 +37,7 @@ class ChwHomePerformanceCheck extends AbstractPerformanceCheck {
// since 04.11.2014 (incl.) // since 04.11.2014 (incl.)
// assertEquals(71, medianSpeedup, 2.1); // +27 // assertEquals(71, medianSpeedup, 2.1); // +27
// since 05.12.2014 (incl.) // since 05.12.2014 (incl.)
assertEquals(45, medianSpeedup, 2.1); // -26 (45-56) assertEquals(43, medianSpeedup, 2.1); // -28 (41-56)
} }
private void checkSingleElementPipes() { private void checkSingleElementPipes() {
......
...@@ -17,12 +17,14 @@ package teetime.examples.experiment09pipeimpls; ...@@ -17,12 +17,14 @@ package teetime.examples.experiment09pipeimpls;
import org.junit.AfterClass; import org.junit.AfterClass;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import teetime.framework.pipe.CommittablePipeFactory; import teetime.framework.pipe.CommittablePipeFactory;
import teetime.framework.pipe.IPipeFactory; import teetime.framework.pipe.IPipeFactory;
import teetime.framework.pipe.OrderedGrowableArrayPipeFactory; import teetime.framework.pipe.OrderedGrowableArrayPipeFactory;
import teetime.framework.pipe.SingleElementPipeFactory; import teetime.framework.pipe.SingleElementPipeFactory;
import teetime.framework.pipe.UnorderedGrowablePipeFactory;
import teetime.util.ConstructorClosure; import teetime.util.ConstructorClosure;
import teetime.util.TimestampObject; import teetime.util.TimestampObject;
import util.test.AbstractProfiledPerformanceAssertion; import util.test.AbstractProfiledPerformanceAssertion;
...@@ -65,6 +67,13 @@ public class MethodCallThoughputTimestampAnalysis9Test extends PerformanceTest { ...@@ -65,6 +67,13 @@ public class MethodCallThoughputTimestampAnalysis9Test extends PerformanceTest {
testWithManyObjects(pipeFactory); testWithManyObjects(pipeFactory);
} }
@Ignore
@Test
public void testUnorderedGrowablePipes() throws Exception { // TODO remove test 11
IPipeFactory pipeFactory = new UnorderedGrowablePipeFactory();
testWithManyObjects(pipeFactory);
}
private void testWithManyObjects(final IPipeFactory pipeFactory) { private void testWithManyObjects(final IPipeFactory pipeFactory) {
System.out.println("Testing teetime (mc) with NUM_OBJECTS_TO_CREATE=" + NUM_OBJECTS_TO_CREATE + ", NUM_NOOP_FILTERS=" System.out.println("Testing teetime (mc) with NUM_OBJECTS_TO_CREATE=" + NUM_OBJECTS_TO_CREATE + ", NUM_NOOP_FILTERS="
+ NUM_NOOP_FILTERS + "..."); + NUM_NOOP_FILTERS + "...");
......
...@@ -57,11 +57,6 @@ public class OldPipeline<FirstStage extends Stage, LastStage extends Stage> exte ...@@ -57,11 +57,6 @@ public class OldPipeline<FirstStage extends Stage, LastStage extends Stage> exte
return firstStage.getInputPorts(); return firstStage.getInputPorts();
} }
@Override
public void setOwningThread(final Thread owningThread) {
firstStage.setOwningThread(owningThread);
}
@Override @Override
public Thread getOwningThread() { public Thread getOwningThread() {
return firstStage.getOwningThread(); return firstStage.getOwningThread();
......
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