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

Set stage state field to volatile and added check in add(), if the

current stage should be terminated
parent adc39144
No related branches found
No related tags found
No related merge requests found
......@@ -34,7 +34,7 @@ public abstract class AbstractStage extends Stage {
private final PortList<InputPort<?>> inputPorts = new PortList<InputPort<?>>();
private final PortList<OutputPort<?>> outputPorts = new PortList<OutputPort<?>>();
private StageState currentState = StageState.CREATED;
private volatile StageState currentState = StageState.CREATED;
@Override
protected List<InputPort<?>> getInputPorts() {
......
......@@ -18,7 +18,7 @@ package teetime.framework.exceptionHandling;
import teetime.framework.Stage;
/**
* Represents an Exception, which is thrown by stages in case of theyimport teetime.framework.Stage;
* Represents an Exception, which is thrown by stages in case of they import teetime.framework.Stage;
* original exception, which was thrown, call {@link #getCause()}. {@link #getThrowingStage()} returns the stage, which has thrown the original exception.
*
* @since 1.1
......
......@@ -39,7 +39,8 @@ final class SpScPipe extends AbstractInterThreadPipe implements IMonitorablePipe
public boolean add(final Object element) {
while (!this.queue.offer(element)) {
// Thread.yield();
if (this.cachedTargetStage.getCurrentState() == StageState.TERMINATED) {
if (this.cachedTargetStage.getCurrentState() == StageState.TERMINATED &&
this.getSourcePort().getOwningStage().getCurrentState() == StageState.TERMINATING) {
return false;
}
this.numWaits++;
......
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