]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db.impl/src/org/simantics/db/impl/graph/ReadGraphImpl.java
Wrong graph was used when performing async query from session
[simantics/platform.git] / bundles / org.simantics.db.impl / src / org / simantics / db / impl / graph / ReadGraphImpl.java
index 2eced2b7c046ebef86a64760cee27106667c706c..48662d1903a08267a13dded57e04e04f8b85db6d 100644 (file)
@@ -5662,7 +5662,7 @@ public class ReadGraphImpl implements AsyncReadGraph {
                this.parentGraph = parentGraph;
                this.parent = parent;
                this.processor = support;
-               this.asyncBarrier = new AsyncBarrierImpl(parentGraph != null ? parentGraph.asyncBarrier : null, parent, null);
+               this.asyncBarrier = prepareBarrier(parentGraph, parent, null, false);
        }
 
     ReadGraphImpl(ReadGraphImpl parentGraph, CacheEntry parent, QueryProcessor support, AsyncBarrierImpl asyncBarrier) {
@@ -5676,34 +5676,30 @@ public class ReadGraphImpl implements AsyncReadGraph {
                this(graph, parent, graph.processor);
        }
 
-    ReadGraphImpl(ReadGraphImpl parentGraph, CacheEntry parent, Runnable callback) {
-        this(parentGraph, parent, parentGraph.processor, new AsyncBarrierImpl(parentGraph != null ? parentGraph.asyncBarrier : null, parent, callback));
+    ReadGraphImpl(ReadGraphImpl parentGraph, CacheEntry parent, Runnable callback, boolean needsToBlock) {
+        this(parentGraph, parent, parentGraph.processor, prepareBarrier(parentGraph, parent, callback, needsToBlock));
     }
 
+    static AsyncBarrierImpl prepareBarrier(ReadGraphImpl parentGraph, CacheEntry parent, Runnable callback, boolean needsToBlock) {
+        return new AsyncBarrierImpl(parentGraph != null ? parentGraph.asyncBarrier : null, parent, callback, needsToBlock);
+    }
+    
        ReadGraphImpl(ReadGraphImpl graph) {
                this(graph, graph.parent);
        }
 
-       public ReadGraphImpl withParent(CacheEntry parent, Runnable callback) {
-               return new ReadGraphImpl(this, parent, callback);
+       public ReadGraphImpl withParent(CacheEntry parent, Runnable callback, boolean needsToBlock) {
+               return new ReadGraphImpl(this, parent, callback, needsToBlock);
        }
 
-    public ReadGraphImpl withParent(CacheEntry parent) {
-        return withParent(parent, null);
-    }
-
-       public ReadGraphImpl syncWithParent(CacheEntry parent) {
-        return new ReadGraphImpl(this, parent, processor, null);
-    }
-
        public ReadGraphImpl forRecompute(CacheEntry parent) {
                return new ReadGraphImpl(null, parent, processor);
        }
 
-       public static ReadGraphImpl create(QueryProcessor support) {
-           ReadGraphImpl result = new ReadGraphImpl(null, null, support);
-           return result;
-       }
+    public static ReadGraphImpl create(QueryProcessor support) {
+        ReadGraphImpl result = new ReadGraphImpl(null, null, support);
+        return result;
+    }
 
        public ReadGraphImpl newRestart(ReadGraphImpl impl) {