]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db.impl/src/org/simantics/db/impl/BlockingAsyncProcedure.java
DB request scheduling scheme fails with district diagrams
[simantics/platform.git] / bundles / org.simantics.db.impl / src / org / simantics / db / impl / BlockingAsyncProcedure.java
index c491fb377464e366f5b34e8e8eac2e0e205840c5..ecb66ff91e3ea5df7aea462e57e5d578608ee970 100644 (file)
@@ -28,6 +28,7 @@ public class BlockingAsyncProcedure<Result> implements AsyncProcedure<Result> {
     public final ReadGraphImpl callerGraph;
     public final AsyncProcedure<Result> procedure;
     public PendingTaskSupport pendingTaskSupport;
+    public final boolean needsToBlock;
     public Object result = NO_RESULT;
     public Throwable exception = null;
 
@@ -36,13 +37,13 @@ public class BlockingAsyncProcedure<Result> implements AsyncProcedure<Result> {
     }
     
     public BlockingAsyncProcedure(ReadGraphImpl callerGraph, AsyncReadEntry<Result> entry, AsyncProcedure<Result> procedure, Object key, boolean needsToBlock) {
-
+        
         // A new graph for evaluating the query with correct parent and asyncBarrier
         queryGraph = callerGraph.withParent(entry, () -> {
 
             dispatchProcedure(queryGraph(), callerGraph, entry, procedure, needsToBlock);
             
-        });
+        }, needsToBlock);
         
         queryGraph.asyncBarrier.inc();
 
@@ -50,6 +51,7 @@ public class BlockingAsyncProcedure<Result> implements AsyncProcedure<Result> {
         this.key = key;
         this.queryGraph.asyncBarrier.inc();
         this.callerGraph = callerGraph;
+        this.needsToBlock = needsToBlock;
         if (BarrierTracing.BOOKKEEPING) {
             BarrierTracing.registerBAP(this);
         }
@@ -84,7 +86,8 @@ public class BlockingAsyncProcedure<Result> implements AsyncProcedure<Result> {
     @SuppressWarnings("unchecked")
     public Result get() throws DatabaseException {
 
-        queryGraph.asyncBarrier.waitBarrier(key, queryGraph);
+        if(needsToBlock)
+            queryGraph.asyncBarrier.waitBarrier(key, queryGraph);
 
         if(exception != null) {
             if(exception instanceof DatabaseException) throw (DatabaseException)exception;
@@ -113,7 +116,7 @@ public class BlockingAsyncProcedure<Result> implements AsyncProcedure<Result> {
         
         AsyncProcedure<Result> procedure = entry != null ? entry : procedure_;
 
-        ReadGraphImpl executeGraph = parentGraph.withParent(parentGraph.parent);
+        ReadGraphImpl executeGraph = parentGraph.withParent(parentGraph.parent, null, needsToBlock);
         executeGraph.asyncBarrier.inc();
         try {
             if(procedure != null) {