]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Allow ExternalReadEntry.compute to continue graph handling 22/4522/1
authorjsimomaa <jani.simomaa@gmail.com>
Mon, 5 Oct 2020 20:11:39 +0000 (23:11 +0300)
committerjsimomaa <jani.simomaa@gmail.com>
Mon, 5 Oct 2020 20:11:39 +0000 (23:11 +0300)
This is a bit hazard as ExternalReads should not fiddle with ThreadLocal
graphs (e.g. SCLContext.getCurrent().get("graph")

gitlab #5

Change-Id: I833113eda418fab9ae5ff4b247a7fa09469ad921

bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/ExternalReadEntry.java

index d044043394ef771f7e7e0cfab3e5257f77883db6..419115165f10f4f46a7fb4083847cbaf3a72905c 100644 (file)
@@ -181,13 +181,15 @@ final public class ExternalReadEntry<T> extends CacheEntryBase<AsyncProcedure<T>
                try {
                        
                        ReadGraphImpl queryGraph = graph.withParent(this, null, true);
+                       queryGraph.asyncBarrier.inc();
 
-                       if(!registered) {
-                               id.register(graph, this);
+                       if (!registered) {
+                               id.register(queryGraph, this);
                                registered = true;
                        }
-                       
-                       queryGraph.asyncBarrier.waitBarrier(id, graph);
+
+                       queryGraph.asyncBarrier.dec();
+                       queryGraph.asyncBarrier.waitBarrier(id, queryGraph);
 
                } catch (Throwable t) {