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

added FIXMEs

parent 3d6ee36d
No related branches found
No related tags found
No related merge requests found
...@@ -21,15 +21,17 @@ public abstract class AbstractInterThreadPipe extends AbstractPipe { ...@@ -21,15 +21,17 @@ public abstract class AbstractInterThreadPipe extends AbstractPipe {
@Override @Override
public void sendSignal(final ISignal signal) { public void sendSignal(final ISignal signal) {
this.signalQueue.offer(signal); this.signalQueue.offer(signal);
System.out.println("send signal: " + signal + " to " + cachedTargetStage);
Thread owningThread = cachedTargetStage.getOwningThread(); Thread owningThread = cachedTargetStage.getOwningThread();
if (null != owningThread && (owningThread.getState() == State.WAITING || owningThread.getState() == State.TIMED_WAITING)) { if (null != owningThread && isThreadWaiting(owningThread)) { // FIXME remove the null check for performance
owningThread.interrupt(); owningThread.interrupt();
System.out.println("interrupted " + owningThread);
} }
} }
protected boolean isThreadWaiting(final Thread thread) {
return thread.getState() == State.WAITING || thread.getState() == State.TIMED_WAITING;
}
/** /**
* Retrieves and removes the head of the signal queue * Retrieves and removes the head of the signal queue
* *
......
package teetime.framework.pipe; package teetime.framework.pipe;
import java.lang.Thread.State;
import java.util.Queue; import java.util.Queue;
import org.jctools.queues.QueueFactory; import org.jctools.queues.QueueFactory;
...@@ -41,7 +40,7 @@ public final class SpScPipe extends AbstractInterThreadPipe { ...@@ -41,7 +40,7 @@ public final class SpScPipe extends AbstractInterThreadPipe {
} }
Thread owningThread = cachedTargetStage.getOwningThread(); Thread owningThread = cachedTargetStage.getOwningThread();
if (null != owningThread && (owningThread.getState() == State.WAITING || owningThread.getState() == State.TIMED_WAITING)) { if (null != owningThread && isThreadWaiting(owningThread)) { // FIXME remove the null check for performance
synchronized (cachedTargetStage) { synchronized (cachedTargetStage) {
cachedTargetStage.notify(); cachedTargetStage.notify();
// LOGGER.trace("Notified: " + cachedTargetStage); // LOGGER.trace("Notified: " + cachedTargetStage);
......
...@@ -9,8 +9,6 @@ import org.junit.Test; ...@@ -9,8 +9,6 @@ import org.junit.Test;
import teetime.util.Pair; import teetime.util.Pair;
import com.google.common.base.Joiner;
public class RunnableConsumerStageTest { public class RunnableConsumerStageTest {
@Test @Test
...@@ -22,7 +20,7 @@ public class RunnableConsumerStageTest { ...@@ -22,7 +20,7 @@ public class RunnableConsumerStageTest {
Thread thread = new Thread(new Runnable() { Thread thread = new Thread(new Runnable() {
@Override @Override
public void run() { public void run() {
start(analysis); start(analysis); // FIXME react on exceptions
} }
}); });
thread.start(); thread.start();
...@@ -42,7 +40,7 @@ public class RunnableConsumerStageTest { ...@@ -42,7 +40,7 @@ public class RunnableConsumerStageTest {
Thread thread = new Thread(new Runnable() { Thread thread = new Thread(new Runnable() {
@Override @Override
public void run() { public void run() {
start(analysis); start(analysis); // FIXME react on exceptions
} }
}); });
thread.start(); thread.start();
...@@ -70,8 +68,9 @@ public class RunnableConsumerStageTest { ...@@ -70,8 +68,9 @@ public class RunnableConsumerStageTest {
private void start(final Analysis analysis) { private void start(final Analysis analysis) {
Collection<Pair<Thread, Throwable>> exceptions = analysis.start(); Collection<Pair<Thread, Throwable>> exceptions = analysis.start();
for (Pair<Thread, Throwable> pair : exceptions) { for (Pair<Thread, Throwable> pair : exceptions) {
System.out.println(pair.getSecond()); // System.out.println(pair.getSecond());
System.out.println(Joiner.on("\n").join(pair.getSecond().getStackTrace())); // System.out.println(Joiner.on("\n").join(pair.getSecond().getStackTrace()));
throw new RuntimeException(pair.getSecond());
} }
assertEquals(0, exceptions.size()); assertEquals(0, exceptions.size());
} }
......
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