Merge "(refs #7567) Added throw function to builtins"
authorHannu Niemistö <hannu.niemisto@semantum.fi>
Fri, 20 Oct 2017 08:53:07 +0000 (11:53 +0300)
committerGerrit Code Review <gerrit2@www.simantics.org>
Fri, 20 Oct 2017 08:53:07 +0000 (11:53 +0300)
bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/State.java
bundles/org.simantics.diagram/src/org/simantics/diagram/elements/DiagramNodeUtil.java

index 5adc593001cd19ae305c5fb3e00dfe181b0003e0..f30418a6a32869bf009fc661baa47244a4679a1b 100644 (file)
@@ -47,7 +47,7 @@ class State {
     private volatile int readCount = 0; // Must be volatile so we don't have to synchronize getReadCount.
     private volatile int writeCount = 0; // Must be volatile so we don't have to synchronize getWriteCount.
     private Thread            writeOwner       = null;
-    private int               asyncCount       = 1;
+    private volatile int asyncCount = 1; // Must be volatile so we don't have to synchronize getAsyncCount.
     private TransactionToken  transactionToken = null;
     void setCombine(boolean a) {
         if (null != transactionToken)
index 893573d0f057841e769e73f7216b22e48b2ba923..f2cccf7749527df9c5d7a851a17040fac3f19ef5 100644 (file)
@@ -14,6 +14,7 @@ import org.simantics.db.common.request.ResourceRead;
 import org.simantics.db.common.request.WriteRequest;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.request.Read;
+import org.simantics.db.service.TransactionSupport;
 import org.simantics.db.service.VirtualGraphSupport;
 import org.simantics.diagram.stubs.DiagramResource;
 import org.simantics.diagram.ui.DiagramModelHints;
@@ -146,22 +147,7 @@ public class DiagramNodeUtil {
         G2DSceneGraph sg = provider.initializeSceneGraph(new G2DSceneGraph(), modelURI, diagramRVI);
 
         NodeUtil.waitPending(cp.getCanvasContext().getThreadAccess(), sg);
-
-        return cp.getCanvasContext();
-    }
-
-    /**
-     * @deprecated this leaks ICanvasSceneGraphProvider, use
-     *             {@link #loadSceneGraphProvider(ICanvasContext, Resource, Resource, String)}
-     *             instead
-     */
-    public static ICanvasContext loadDiagram(ICanvasContext context, Resource model, Resource composite, String diagramRVI) throws DatabaseException, InterruptedException {
-        String modelURI = Simantics.getSession().syncRequest(Queries.uri(model));
-        ISceneGraphProvider provider = Simantics.getSession().syncRequest( Queries.adapt( composite, ISceneGraphProvider.class ) );
-        ICanvasSceneGraphProvider cp = (ICanvasSceneGraphProvider) provider;
-        cp.initializeSceneGraph(context, modelURI, diagramRVI);
-
-        NodeUtil.waitPending(cp.getCanvasContext().getThreadAccess(), context.getSceneGraph());
+        Simantics.getSession().getService(TransactionSupport.class).waitCompletion();
 
         return cp.getCanvasContext();
     }
@@ -173,6 +159,7 @@ public class DiagramNodeUtil {
         G2DSceneGraph sg = cp.initializeSceneGraph(new G2DSceneGraph(), modelURI, diagramRVI);
 
         NodeUtil.waitPending(cp.getCanvasContext().getThreadAccess(), sg);
+        Simantics.getSession().getService(TransactionSupport.class).waitCompletion();
 
         return cp;
     }
@@ -188,6 +175,7 @@ public class DiagramNodeUtil {
         ICanvasSceneGraphProvider cp = (ICanvasSceneGraphProvider) provider;
         cp.initializeSceneGraph(context, modelURI, diagramRVI);
         NodeUtil.waitPending(cp.getCanvasContext().getThreadAccess(), context.getSceneGraph(), timeoutMs);
+        Simantics.getSession().getService(TransactionSupport.class).waitCompletion();
         return cp;
     }
 
@@ -197,6 +185,7 @@ public class DiagramNodeUtil {
         ICanvasSceneGraphProvider cp = (ICanvasSceneGraphProvider) provider;
         cp.initializeSceneGraph(context, modelURI, diagramRVI);
         NodeUtil.waitPending(cp.getCanvasContext().getThreadAccess(), context.getSceneGraph());
+        Simantics.getSession().getService(TransactionSupport.class).waitCompletion();
         return cp;
     }