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

removed WaitStrategy temporarily due to bad implementation

parent 747f1eb3
No related branches found
No related tags found
No related merge requests found
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.m2e.Maven2LaunchConfigurationType">
<booleanAttribute key="M2_DEBUG_OUTPUT" value="false"/>
<stringAttribute key="M2_GOALS" value="install"/>
<booleanAttribute key="M2_NON_RECURSIVE" value="false"/>
<booleanAttribute key="M2_OFFLINE" value="false"/>
<stringAttribute key="M2_PROFILES" value=""/>
<listAttribute key="M2_PROPERTIES"/>
<stringAttribute key="M2_RUNTIME" value="EMBEDDED"/>
<booleanAttribute key="M2_SKIP_TESTS" value="true"/>
<intAttribute key="M2_THREADS" value="1"/>
<booleanAttribute key="M2_UPDATE_SNAPSHOTS" value="false"/>
<stringAttribute key="M2_USER_SETTINGS" value=""/>
<booleanAttribute key="M2_WORKSPACE_RESOLUTION" value="false"/>
<stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY" value="I:/Repositories/teetime"/>
</launchConfiguration>
/**
* Copyright (C) 2015 TeeTime (http://teetime.sourceforge.net)
*
* 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.idle;
import teetime.framework.Stage;
public final class WaitStrategy implements IdleStrategy {
private final Stage stage;
public WaitStrategy(final Stage stage) {
super();
this.stage = stage;
}
@Override
public void execute() throws InterruptedException {
synchronized (stage) {
stage.wait();
}
}
}
...@@ -53,15 +53,6 @@ public final class SpScPipe extends AbstractInterThreadPipe { ...@@ -53,15 +53,6 @@ public final class SpScPipe extends AbstractInterThreadPipe {
this.numWaits++; this.numWaits++;
Thread.yield(); Thread.yield();
} }
Thread owningThread = cachedTargetStage.getOwningThread();
if (null != owningThread && isThreadWaiting(owningThread)) { // FIXME remove the null check for performance
synchronized (cachedTargetStage) {
cachedTargetStage.notify();
// LOGGER.trace("Notified: " + cachedTargetStage);
}
}
return true; return true;
} }
......
...@@ -17,7 +17,6 @@ package teetime.framework; ...@@ -17,7 +17,6 @@ package teetime.framework;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import java.lang.Thread.State;
import java.util.Collection; import java.util.Collection;
import org.junit.Test; import org.junit.Test;
...@@ -28,44 +27,44 @@ import com.google.common.base.Joiner; ...@@ -28,44 +27,44 @@ import com.google.common.base.Joiner;
public class RunnableConsumerStageTest { public class RunnableConsumerStageTest {
@Test // @Test
public void testWaitingInfinitely() throws Exception { // public void testWaitingInfinitely() throws Exception {
WaitStrategyConfiguration waitStrategyConfiguration = new WaitStrategyConfiguration(300, 42); // WaitStrategyConfiguration waitStrategyConfiguration = new WaitStrategyConfiguration(300, 42);
//
final Analysis analysis = new Analysis(waitStrategyConfiguration); // final Analysis analysis = new Analysis(waitStrategyConfiguration);
Thread thread = new Thread(new Runnable() { // Thread thread = new Thread(new Runnable() {
@Override // @Override
public void run() { // public void run() {
start(analysis); // FIXME react on exceptions // start(analysis); // FIXME react on exceptions
} // }
}); // });
thread.start(); // thread.start();
//
Thread.sleep(200); // Thread.sleep(200);
//
assertEquals(State.WAITING, thread.getState()); // assertEquals(State.WAITING, thread.getState());
assertEquals(0, waitStrategyConfiguration.getCollectorSink().getElements().size()); // assertEquals(0, waitStrategyConfiguration.getCollectorSink().getElements().size());
} // }
//
@Test // @Test
public void testWaitingFinitely() throws Exception { // public void testWaitingFinitely() throws Exception {
WaitStrategyConfiguration waitStrategyConfiguration = new WaitStrategyConfiguration(300, 42); // WaitStrategyConfiguration waitStrategyConfiguration = new WaitStrategyConfiguration(300, 42);
//
final Analysis analysis = new Analysis(waitStrategyConfiguration); // final Analysis analysis = new Analysis(waitStrategyConfiguration);
Thread thread = new Thread(new Runnable() { // Thread thread = new Thread(new Runnable() {
@Override // @Override
public void run() { // public void run() {
start(analysis); // FIXME react on exceptions // start(analysis); // FIXME react on exceptions
} // }
}); // });
thread.start(); // thread.start();
//
Thread.sleep(400); // Thread.sleep(400);
//
assertEquals(State.TERMINATED, thread.getState()); // assertEquals(State.TERMINATED, thread.getState());
assertEquals(42, waitStrategyConfiguration.getCollectorSink().getElements().get(0)); // assertEquals(42, waitStrategyConfiguration.getCollectorSink().getElements().get(0));
assertEquals(1, waitStrategyConfiguration.getCollectorSink().getElements().size()); // assertEquals(1, waitStrategyConfiguration.getCollectorSink().getElements().size());
} // }
@Test @Test
public void testYieldRun() throws Exception { public void testYieldRun() throws Exception {
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
*/ */
package teetime.framework; package teetime.framework;
import teetime.framework.idle.WaitStrategy;
import teetime.framework.pipe.IPipeFactory; import teetime.framework.pipe.IPipeFactory;
import teetime.framework.pipe.PipeFactoryRegistry.PipeOrdering; import teetime.framework.pipe.PipeFactoryRegistry.PipeOrdering;
import teetime.framework.pipe.PipeFactoryRegistry.ThreadCommunication; import teetime.framework.pipe.PipeFactoryRegistry.ThreadCommunication;
...@@ -69,7 +68,7 @@ class WaitStrategyConfiguration extends AnalysisConfiguration { ...@@ -69,7 +68,7 @@ class WaitStrategyConfiguration extends AnalysisConfiguration {
Relay<Object> relay = new Relay<Object>(); Relay<Object> relay = new Relay<Object>();
CollectorSink<Object> collectorSink = new CollectorSink<Object>(); CollectorSink<Object> collectorSink = new CollectorSink<Object>();
relay.setIdleStrategy(new WaitStrategy(relay)); // relay.setIdleStrategy(new WaitStrategy(relay));
interThreadPipeFactory.create(delay.getOutputPort(), relay.getInputPort()); interThreadPipeFactory.create(delay.getOutputPort(), relay.getInputPort());
intraThreadPipeFactory.create(relay.getOutputPort(), collectorSink.getInputPort()); intraThreadPipeFactory.create(relay.getOutputPort(), collectorSink.getInputPort());
......
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