Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEd Willink2016-10-08 16:03:55 +0000
committerEd Willink2016-10-30 11:37:07 +0000
commita86d3b30f8df7ae9a2e2e8b5d7c32040ed7d3eac (patch)
tree9eecc1879daf00319da0c9b7f1f0dd3e75cf9f26 /plugins
parentc6a0ba01d59c0f4b783a44aa20ed79707f5b84f5 (diff)
downloadorg.eclipse.qvtd-a86d3b30f8df7ae9a2e2e8b5d7c32040ed7d3eac.tar.gz
org.eclipse.qvtd-a86d3b30f8df7ae9a2e2e8b5d7c32040ed7d3eac.tar.xz
org.eclipse.qvtd-a86d3b30f8df7ae9a2e2e8b5d7c32040ed7d3eac.zip
[500962] Delegate InvocationManagement to a single Interval
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.qvtd.codegen/src/org/eclipse/qvtd/codegen/qvti/java/QVTiCG2JavaVisitor.java5
-rw-r--r--plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/evaluation/Execution2GraphVisitor.java2
-rw-r--r--plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/evaluation/QVTiIncrementalExecutor.java4
-rw-r--r--plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/AbstractExecutionVisitor.java6
-rw-r--r--plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/AbstractInvocation.java7
-rw-r--r--plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/AbstractObjectManager.java5
-rw-r--r--plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/ExecutionVisitor.java1
-rw-r--r--plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/Interval.java36
-rw-r--r--plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/Invocation.java4
-rw-r--r--plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/InvocationManager.java3
-rw-r--r--plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/ObjectManager.java2
-rw-r--r--plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/internal/evaluation/AbstractIntervalInternal.java192
-rw-r--r--plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/internal/evaluation/AbstractInvocationInternal.java17
-rw-r--r--plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/internal/evaluation/AbstractInvocationManagerInternal.java109
-rw-r--r--plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/internal/evaluation/AbstractTransformerInternal.java4
-rw-r--r--plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/internal/evaluation/IncrementalObjectManager.java4
-rw-r--r--plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/internal/evaluation/LazyObjectManager.java4
17 files changed, 280 insertions, 125 deletions
diff --git a/plugins/org.eclipse.qvtd.codegen/src/org/eclipse/qvtd/codegen/qvti/java/QVTiCG2JavaVisitor.java b/plugins/org.eclipse.qvtd.codegen/src/org/eclipse/qvtd/codegen/qvti/java/QVTiCG2JavaVisitor.java
index 312ba759c..01fcc778d 100644
--- a/plugins/org.eclipse.qvtd.codegen/src/org/eclipse/qvtd/codegen/qvti/java/QVTiCG2JavaVisitor.java
+++ b/plugins/org.eclipse.qvtd.codegen/src/org/eclipse/qvtd/codegen/qvti/java/QVTiCG2JavaVisitor.java
@@ -969,7 +969,10 @@ public class QVTiCG2JavaVisitor extends CG2JavaVisitor<@NonNull QVTiCodeGenerato
js.append(" [] boundValues) {\n");
js.pushIndentation(null);
if (isIncremental) {
- js.append("super(constructor);\n");
+ js.append("super(invocationManager.getDefaultInterval(), constructor);\n");
+ }
+ else {
+ js.append("super(invocationManager.getDefaultInterval());\n");
}
int i = 0;
for (@NonNull CGGuardVariable cgFreeVariable : cgFreeVariables) {
diff --git a/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/evaluation/Execution2GraphVisitor.java b/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/evaluation/Execution2GraphVisitor.java
index bc8e14e91..7cec34d73 100644
--- a/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/evaluation/Execution2GraphVisitor.java
+++ b/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/evaluation/Execution2GraphVisitor.java
@@ -39,7 +39,7 @@ import org.eclipse.qvtd.runtime.evaluation.Transformer;
import com.google.common.collect.Iterables;
-public class Execution2GraphVisitor extends AbstractExecutionVisitor<String>
+public class Execution2GraphVisitor extends AbstractExecutionVisitor<@Nullable Object>
{
protected static final class ExecutionEdge implements GraphEdge
{
diff --git a/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/evaluation/QVTiIncrementalExecutor.java b/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/evaluation/QVTiIncrementalExecutor.java
index 9effec8a8..afb96a50c 100644
--- a/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/evaluation/QVTiIncrementalExecutor.java
+++ b/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/evaluation/QVTiIncrementalExecutor.java
@@ -167,7 +167,7 @@ public class QVTiIncrementalExecutor extends BasicQVTiExecutor
{
@Override
public @NonNull Invocation newInstance(@NonNull Object @NonNull [] theseValues) {
- Invocation.Incremental invocation = new AbstractInvocation.Incremental(this)
+ Invocation.Incremental invocation = new AbstractInvocation.Incremental(invocationManager.getDefaultInterval(), this)
{
protected Object returnStatus;
@@ -212,7 +212,7 @@ public class QVTiIncrementalExecutor extends BasicQVTiExecutor
if (debugInvocations) {
AbstractTransformer.INVOCATIONS.println("invoke " + invocation);
}
- invocationManager.invoke(invocation, true);
+ invocation.invokeInternal(true);
}
return null;
}
diff --git a/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/AbstractExecutionVisitor.java b/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/AbstractExecutionVisitor.java
index d45203e64..556880538 100644
--- a/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/AbstractExecutionVisitor.java
+++ b/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/AbstractExecutionVisitor.java
@@ -33,6 +33,11 @@ public /*abstract*/ class AbstractExecutionVisitor<R> implements ExecutionVisito
}
@Override
+ public R visitInterval(@NonNull Interval object) {
+ return visiting(object);
+ }
+
+ @Override
public R visitInvocation(@NonNull Invocation object) {
return visiting(object);
}
@@ -56,5 +61,4 @@ public /*abstract*/ class AbstractExecutionVisitor<R> implements ExecutionVisito
public R visitTransformer(@NonNull Transformer object) {
return visiting(object);
}
-
}
diff --git a/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/AbstractInvocation.java b/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/AbstractInvocation.java
index 197652e0b..d833b2fa3 100644
--- a/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/AbstractInvocation.java
+++ b/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/AbstractInvocation.java
@@ -35,7 +35,8 @@ public abstract class AbstractInvocation extends AbstractInvocationInternal
private Set<SlotState.@NonNull Incremental> readSlots = null;
private Set<SlotState.@NonNull Incremental> writeSlots = null;
- protected Incremental(Invocation.Constructor.@NonNull Incremental constructor) {
+ protected Incremental(@NonNull Interval interval, Invocation.Constructor.@NonNull Incremental constructor) {
+ super(interval);
this.constructor = constructor;
this.sequence = constructor.nextSequence();
}
@@ -92,6 +93,10 @@ public abstract class AbstractInvocation extends AbstractInvocationInternal
}
}
+ protected AbstractInvocation(@NonNull Interval interval) {
+ super(interval);
+ }
+
@Override
public <R> R accept(@NonNull ExecutionVisitor<R> visitor) {
return visitor.visitInvocation(this);
diff --git a/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/AbstractObjectManager.java b/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/AbstractObjectManager.java
index 6a777bb11..1c64d3f23 100644
--- a/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/AbstractObjectManager.java
+++ b/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/AbstractObjectManager.java
@@ -33,9 +33,4 @@ public abstract class AbstractObjectManager implements ObjectManager
public <R> R accept(@NonNull ExecutionVisitor<R> visitor) {
return visitor.visitObjectManager(this);
}
-
- @Override
- public void unblock(@NonNull Invocation anInvocation) {
- invocationManager.unblock(anInvocation);
- }
} \ No newline at end of file
diff --git a/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/ExecutionVisitor.java b/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/ExecutionVisitor.java
index 4737bf3fd..3b8b2d8b6 100644
--- a/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/ExecutionVisitor.java
+++ b/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/ExecutionVisitor.java
@@ -26,6 +26,7 @@ public interface ExecutionVisitor<R>
// R visiting(@NonNull ExecutionVisitable visitable);
R visitComputation(@NonNull Computation object);
+ R visitInterval(@NonNull Interval object);
R visitInvocation(@NonNull Invocation object);
R visitInvocationManager(@NonNull InvocationManager object);
R visitObjectManager(@NonNull ObjectManager object);
diff --git a/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/Interval.java b/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/Interval.java
new file mode 100644
index 000000000..bcc0f674b
--- /dev/null
+++ b/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/Interval.java
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2016 Willink Transformations and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * E.D.Willink - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.qvtd.runtime.evaluation;
+
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.ocl.pivot.utilities.Nameable;
+
+/**
+ * An Interval identifies one of the scheduler time slots. Invocations associated with one Interval may rely on
+ * Invocatuions in earlier intervals completing before they start.
+ *
+ * @noimplement clients should derive from AbstractInterval
+ */
+public interface Interval extends ExecutionVisitable, Nameable
+{
+ boolean flush();
+
+ @NonNull InvocationManager getInvocationManager();
+
+ @Override
+ @NonNull String getName();
+
+ void invoke(@NonNull Invocation invocation, boolean doFlush);
+
+ void queue(@NonNull Invocation consumer);
+
+ void unblock(@NonNull Invocation invocation);
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/Invocation.java b/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/Invocation.java
index 919d74dde..f6b72e80d 100644
--- a/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/Invocation.java
+++ b/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/Invocation.java
@@ -33,6 +33,8 @@ public interface Invocation extends ExecutionVisitable
*/
void insertAfter(@NonNull Invocation predecessor);
+ void invokeInternal(boolean doFlush);
+
/**
* Return true if an occurrence with thoseValues would be a re-occurrence.
*/
@@ -44,6 +46,8 @@ public interface Invocation extends ExecutionVisitable
*/
void remove();
+ void unblock();
+
public interface Constructor extends Nameable
{
public interface Incremental extends Constructor
diff --git a/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/InvocationManager.java b/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/InvocationManager.java
index 8b962ea31..7ff9046c4 100644
--- a/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/InvocationManager.java
+++ b/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/InvocationManager.java
@@ -22,6 +22,5 @@ import org.eclipse.jdt.annotation.NonNull;
public interface InvocationManager extends ExecutionVisitable
{
boolean flush();
- void invoke(@NonNull Invocation invocation, boolean doFlush);
- void unblock(@NonNull Invocation invocation);
+ @NonNull Interval getDefaultInterval();
}
diff --git a/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/ObjectManager.java b/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/ObjectManager.java
index f3ce16c12..41877374b 100644
--- a/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/ObjectManager.java
+++ b/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/ObjectManager.java
@@ -53,6 +53,4 @@ public interface ObjectManager extends ExecutionVisitable
* Identify that the read of eFeature of eObject return ecoreValue.
*/
void got(Invocation.@NonNull Incremental invocation, @NonNull Object eObject, /*@NonNull*/ EStructuralFeature eFeature, @Nullable Object ecoreValue);
-
- void unblock(@NonNull Invocation anInvocation);
}
diff --git a/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/internal/evaluation/AbstractIntervalInternal.java b/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/internal/evaluation/AbstractIntervalInternal.java
new file mode 100644
index 000000000..69b3e3e05
--- /dev/null
+++ b/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/internal/evaluation/AbstractIntervalInternal.java
@@ -0,0 +1,192 @@
+/*******************************************************************************
+ * Copyright (c) 2016 Willink Transformations and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * E.D.Willink - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.qvtd.runtime.internal.evaluation;
+
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
+import org.eclipse.qvtd.runtime.evaluation.AbstractTransformer;
+import org.eclipse.qvtd.runtime.evaluation.ExecutionVisitor;
+import org.eclipse.qvtd.runtime.evaluation.Interval;
+import org.eclipse.qvtd.runtime.evaluation.Invocation;
+import org.eclipse.qvtd.runtime.evaluation.InvocationFailedException;
+import org.eclipse.qvtd.runtime.evaluation.InvocationManager;
+import org.eclipse.qvtd.runtime.evaluation.SlotState;
+
+/**
+ * AbstractIntervalInternal provides the shared implementation of the intrusive blocked/waiting linked list functionality.
+ */
+public abstract class AbstractIntervalInternal implements Interval
+{
+ protected final boolean debugInvocations = AbstractTransformer.INVOCATIONS.isActive();
+
+ protected final @NonNull InvocationManager invocationManager;
+ protected final int intervalIndex;
+
+ /**
+ * Head of doubly linked list of blocked invocations.
+ */
+ private @Nullable AbstractInvocationInternal blockedInvocations = null;
+
+ /**
+ * Head of doubly linked list of unblocked invocations waiting for a re-execution attempt.
+ */
+ private @Nullable AbstractInvocationInternal waitingInvocations = null;
+
+
+ public AbstractIntervalInternal(@NonNull InvocationManager invocationManager, int intervalIndex) {
+ this.invocationManager = invocationManager;
+ this.intervalIndex = intervalIndex;
+ }
+
+ @Override
+ public <R> R accept(@NonNull ExecutionVisitor<R> visitor) {
+ return visitor.visitInterval(this);
+ }
+
+ private synchronized void block(@NonNull Invocation invocation, @NonNull SlotState slotState) {
+ AbstractInvocationInternal castInvocation = (AbstractInvocationInternal) invocation;
+ assert castInvocation.debug_blockedBy == null;
+ castInvocation.debug_blockedBy = slotState;
+ AbstractInvocationInternal blockedInvocations2 = blockedInvocations;
+ if (blockedInvocations2 == null) {
+ blockedInvocations = castInvocation;
+ }
+ else {
+ castInvocation.insertAfter(blockedInvocations2.prev);
+ }
+ slotState.block(invocation);
+ if (debugInvocations) {
+ AbstractTransformer.INVOCATIONS.println("block " + invocation + " for " + slotState);
+ }
+ }
+
+ @Override
+ public boolean flush() {
+ flushInternal();
+ AbstractInvocationInternal blockedInvocation = blockedInvocations;
+ if (blockedInvocation == null) {
+ return true;
+ }
+ do {
+ if (debugInvocations) {
+ AbstractTransformer.INVOCATIONS.println("still blocked " + blockedInvocation + " by " + blockedInvocation.debug_blockedBy);
+ }
+ blockedInvocation = blockedInvocation.next;
+ }
+ while (blockedInvocation != blockedInvocations);
+ return false;
+ }
+
+ private void flushInternal() {
+ while (waitingInvocations != null) {
+ AbstractInvocationInternal invocation = null;
+ synchronized (this) {
+ AbstractInvocationInternal waitingInvocations2 = waitingInvocations;
+ if (waitingInvocations2 != null) {
+ invocation = waitingInvocations2;
+ waitingInvocations = waitingInvocations2.next;
+ if (waitingInvocations == invocation) {
+ waitingInvocations = null;
+ }
+ invocation.remove();
+ }
+ }
+ if (invocation != null) {
+ if (debugInvocations) {
+ AbstractTransformer.INVOCATIONS.println("re-invoke " + invocation);
+ }
+ invoke(invocation, false);
+ }
+ }
+ }
+
+ @Override
+ public @NonNull InvocationManager getInvocationManager() {
+ return invocationManager;
+ }
+
+ @Override
+ public @NonNull String getName() {
+ return String.valueOf(intervalIndex);
+ }
+
+ @Override
+ public void invoke(@NonNull Invocation invocation, boolean doFlush) {
+ try {
+ invocation.execute();
+ if (debugInvocations) {
+ AbstractTransformer.INVOCATIONS.println("done " + invocation);
+ }
+ if (doFlush) {
+ flushInternal();
+ }
+ }
+ catch (InvocationFailedException e) {
+ block(invocation, e.slotState);
+ }
+ }
+
+ @Override
+ public synchronized void queue(@NonNull Invocation invocation) {
+ if (debugInvocations) {
+ AbstractTransformer.INVOCATIONS.println("queue " + invocation);
+ }
+ AbstractInvocationInternal castInvocation = (AbstractInvocationInternal) invocation;
+ assert castInvocation.debug_blockedBy == null;
+ assert blockedInvocations != castInvocation;
+ AbstractInvocationInternal waitingInvocations2 = waitingInvocations;
+ if (waitingInvocations2 == null) {
+ waitingInvocations = castInvocation;
+ }
+ else {
+ castInvocation.insertAfter(waitingInvocations2.prev);
+ }
+ // queue();
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder s = new StringBuilder();
+ s.append(intervalIndex);
+ // s.append(": ");
+ // int i = 0;
+ // for (@NonNull ConnectionLinkage nextConnectionLinkage = nextConnection; nextConnectionLinkage != this; nextConnectionLinkage = nextConnectionLinkage.nextConnection) {
+ // i++;
+ // }
+ // s.append(i);
+ return s.toString();
+ }
+
+ @Override
+ public synchronized void unblock(@NonNull Invocation invocation) {
+ if (debugInvocations) {
+ AbstractTransformer.INVOCATIONS.println("unblock " + invocation);
+ }
+ AbstractInvocationInternal castInvocation = (AbstractInvocationInternal) invocation;
+ assert castInvocation.debug_blockedBy != null;
+ castInvocation.debug_blockedBy = null;
+ if (blockedInvocations == castInvocation) {
+ blockedInvocations = castInvocation.next;
+ if (blockedInvocations == castInvocation) {
+ blockedInvocations = null;
+ }
+ }
+ castInvocation.remove();
+ AbstractInvocationInternal waitingInvocations2 = waitingInvocations;
+ if (waitingInvocations2 == null) {
+ waitingInvocations = castInvocation;
+ }
+ else {
+ castInvocation.insertAfter(waitingInvocations2.prev);
+ }
+ // queue();
+ }
+}
diff --git a/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/internal/evaluation/AbstractInvocationInternal.java b/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/internal/evaluation/AbstractInvocationInternal.java
index 8a673f3c3..f5f20660c 100644
--- a/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/internal/evaluation/AbstractInvocationInternal.java
+++ b/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/internal/evaluation/AbstractInvocationInternal.java
@@ -12,6 +12,7 @@ package org.eclipse.qvtd.runtime.internal.evaluation;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
+import org.eclipse.qvtd.runtime.evaluation.Interval;
import org.eclipse.qvtd.runtime.evaluation.Invocation;
import org.eclipse.qvtd.runtime.evaluation.SlotState;
@@ -20,10 +21,16 @@ import org.eclipse.qvtd.runtime.evaluation.SlotState;
*/
public abstract class AbstractInvocationInternal implements Invocation
{
+ protected final @NonNull Interval interval;
@NonNull AbstractInvocationInternal prev = this;
@NonNull AbstractInvocationInternal next = this;
public @Nullable SlotState debug_blockedBy = null;
+ protected AbstractInvocationInternal(@NonNull Interval interval) {
+ this.interval = interval;
+ // too soon interval.queue(this);
+ }
+
@Override
public void insertAfter(@NonNull Invocation predecessor) {
@NonNull AbstractInvocationInternal castPredecessor = (AbstractInvocationInternal)predecessor;
@@ -35,6 +42,11 @@ public abstract class AbstractInvocationInternal implements Invocation
}
@Override
+ public void invokeInternal(boolean doFlush) {
+ interval.invoke(this, doFlush);
+ }
+
+ @Override
public void remove() {
prev.next = next;
next.prev = prev;
@@ -46,4 +58,9 @@ public abstract class AbstractInvocationInternal implements Invocation
public String toString() {
return getClass().getSimpleName() + "@" + Integer.toHexString(System.identityHashCode(this));
}
+
+ @Override
+ public void unblock() {
+ interval.unblock(this);
+ }
} \ No newline at end of file
diff --git a/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/internal/evaluation/AbstractInvocationManagerInternal.java b/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/internal/evaluation/AbstractInvocationManagerInternal.java
index f80262e6b..1714fe31c 100644
--- a/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/internal/evaluation/AbstractInvocationManagerInternal.java
+++ b/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/internal/evaluation/AbstractInvocationManagerInternal.java
@@ -11,122 +11,23 @@
package org.eclipse.qvtd.runtime.internal.evaluation;
import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.qvtd.runtime.evaluation.AbstractInvocationManager;
-import org.eclipse.qvtd.runtime.evaluation.AbstractTransformer;
-import org.eclipse.qvtd.runtime.evaluation.Invocation;
-import org.eclipse.qvtd.runtime.evaluation.InvocationFailedException;
-import org.eclipse.qvtd.runtime.evaluation.SlotState;
+import org.eclipse.qvtd.runtime.evaluation.Interval;
/**
* InvocationManager supervises and provides thread safety for the lists of blocked and waiting invocations.
*/
public class AbstractInvocationManagerInternal extends AbstractInvocationManager
{
- /**
- * Head of doubly linked list of blocked invocations.
- */
- private @Nullable AbstractInvocationInternal blockedInvocations = null;
-
- /**
- * Head of doubly linked list of unblocked invocations waiting for a re-execution attempt.
- */
- private @Nullable AbstractInvocationInternal waitingInvocations = null;
-
- private synchronized void block(@NonNull Invocation invocation, @NonNull SlotState slotState) {
- AbstractInvocationInternal castInvocation = (AbstractInvocationInternal) invocation;
- assert castInvocation.debug_blockedBy == null;
- castInvocation.debug_blockedBy = slotState;
- AbstractInvocationInternal blockedInvocations2 = blockedInvocations;
- if (blockedInvocations2 == null) {
- blockedInvocations = castInvocation;
- }
- else {
- castInvocation.insertAfter(blockedInvocations2.prev);
- }
- slotState.block(invocation);
- if (debugInvocations) {
- AbstractTransformer.INVOCATIONS.println("block " + invocation + " for " + slotState);
- }
- }
+ private final @NonNull Interval interval = new AbstractIntervalInternal(this, 0) {};
@Override
public boolean flush() {
- flushInternal();
- AbstractInvocationInternal blockedInvocation = blockedInvocations;
- if (blockedInvocation == null) {
- return true;
- }
- do {
- if (debugInvocations) {
- AbstractTransformer.INVOCATIONS.println("still blocked " + blockedInvocation + " by " + blockedInvocation.debug_blockedBy);
- }
- blockedInvocation = blockedInvocation.next;
- }
- while (blockedInvocation != blockedInvocations);
- return false;
- }
-
- private void flushInternal() {
- while (waitingInvocations != null) {
- AbstractInvocationInternal invocation = null;
- synchronized (this) {
- AbstractInvocationInternal waitingInvocations2 = waitingInvocations;
- if (waitingInvocations2 != null) {
- invocation = waitingInvocations2;
- waitingInvocations = waitingInvocations2.next;
- if (waitingInvocations == invocation) {
- waitingInvocations = null;
- }
- invocation.remove();
- }
- }
- if (invocation != null) {
- if (debugInvocations) {
- AbstractTransformer.INVOCATIONS.println("re-invoke " + invocation);
- }
- invoke(invocation, false);
- }
- }
- }
-
- @Override
- public void invoke(@NonNull Invocation invocation, boolean doFlush) {
- try {
- invocation.execute();
- if (debugInvocations) {
- AbstractTransformer.INVOCATIONS.println("done " + invocation);
- }
- if (doFlush) {
- flushInternal();
- }
- }
- catch (InvocationFailedException e) {
- block(invocation, e.slotState);
- }
+ return interval.flush();
}
@Override
- public synchronized void unblock(@NonNull Invocation invocation) {
- if (debugInvocations) {
- AbstractTransformer.INVOCATIONS.println("unblock " + invocation);
- }
- AbstractInvocationInternal castInvocation = (AbstractInvocationInternal) invocation;
- assert castInvocation.debug_blockedBy != null;
- castInvocation.debug_blockedBy = null;
- if (blockedInvocations == castInvocation) {
- blockedInvocations = castInvocation.next;
- if (blockedInvocations == castInvocation) {
- blockedInvocations = null;
- }
- }
- castInvocation.remove();
- AbstractInvocationInternal waitingInvocations2 = waitingInvocations;
- if (waitingInvocations2 == null) {
- waitingInvocations = castInvocation;
- }
- else {
- castInvocation.insertAfter(waitingInvocations2.prev);
- }
+ public @NonNull Interval getDefaultInterval() {
+ return interval;
}
} \ No newline at end of file
diff --git a/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/internal/evaluation/AbstractTransformerInternal.java b/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/internal/evaluation/AbstractTransformerInternal.java
index e12b8dcf2..f4b6aecb7 100644
--- a/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/internal/evaluation/AbstractTransformerInternal.java
+++ b/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/internal/evaluation/AbstractTransformerInternal.java
@@ -732,7 +732,7 @@ public abstract class AbstractTransformerInternal extends AbstractModelManager i
if (debugInvocations) {
AbstractTransformer.INVOCATIONS.println("invoke " + invocation);
}
- invocationManager.invoke(invocation, true);
+ invocation.invokeInternal(true);
}
/**
@@ -744,7 +744,7 @@ public abstract class AbstractTransformerInternal extends AbstractModelManager i
if (debugInvocations) {
AbstractTransformer.INVOCATIONS.println("invokeOnce " + invocation);
}
- invocationManager.invoke(invocation, true);
+ invocation.invokeInternal(true);
}
}
}
diff --git a/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/internal/evaluation/IncrementalObjectManager.java b/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/internal/evaluation/IncrementalObjectManager.java
index 70a22ee15..c4be78867 100644
--- a/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/internal/evaluation/IncrementalObjectManager.java
+++ b/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/internal/evaluation/IncrementalObjectManager.java
@@ -131,13 +131,13 @@ public class IncrementalObjectManager extends AbstractObjectManager
protected synchronized void unblock(@NonNull ObjectManager objectManager) {
final Object blockedInvocations2 = blockedInvocations;
if (blockedInvocations2 instanceof Invocation) {
- objectManager.unblock((Invocation) blockedInvocations2);
+ ((Invocation) blockedInvocations2).unblock();
}
else if (blockedInvocations2 != null) {
@SuppressWarnings("unchecked")
List<Invocation> blockedInvocationList = (List<Invocation>)blockedInvocations2;
for (@SuppressWarnings("null")@NonNull Invocation invocation : blockedInvocationList) {
- objectManager.unblock(invocation);
+ invocation.unblock();
}
}
blockedInvocations = null;
diff --git a/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/internal/evaluation/LazyObjectManager.java b/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/internal/evaluation/LazyObjectManager.java
index 6aa2638ff..15705ceda 100644
--- a/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/internal/evaluation/LazyObjectManager.java
+++ b/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/internal/evaluation/LazyObjectManager.java
@@ -222,13 +222,13 @@ public class LazyObjectManager extends AbstractObjectManager
protected synchronized void unblock(@NonNull ObjectManager objectManager) {
final Object blockedInvocations2 = blockedInvocations;
if (blockedInvocations2 instanceof Invocation) {
- objectManager.unblock((Invocation) blockedInvocations2);
+ ((Invocation) blockedInvocations2).unblock();
}
else if (blockedInvocations2 != null) {
@SuppressWarnings("unchecked")
List<Invocation> blockedInvocationList = (List<Invocation>)blockedInvocations2;
for (@SuppressWarnings("null")@NonNull Invocation invocation : blockedInvocationList) {
- objectManager.unblock(invocation);
+ invocation.unblock();
}
}
blockedInvocations = null;

Back to the top