]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Resolve "A tag with an associated listener causes issues in DelayedWrite 87/4887/1
authorMarko Luukkainen <marko.luukkainen@semantum.fi>
Mon, 7 Feb 2022 14:56:25 +0000 (16:56 +0200)
committerMarko Luukkainen <marko.luukkainen@semantum.fi>
Mon, 7 Feb 2022 14:56:25 +0000 (16:56 +0200)
transactions"

Merged master/2cfb8969 to 1.43.1 manually.

gitlab #761

Change-Id: I65961a7bf3a295bfd14bf0677ed9791c5c7aabc1

bundles/org.simantics.db.impl/src/org/simantics/db/impl/graph/ReadGraphImpl.java
bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/QueryListening.java
bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/QueryProcessor.java
bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/State.java

index 776b448bfb05e196163425d280f62b24f5aaae3c..8baacb10f909fbc0b88f331dd3a23ddbf538817e 100644 (file)
@@ -5686,6 +5686,10 @@ public class ReadGraphImpl implements AsyncReadGraph {
        public ReadGraphImpl forRecompute(CacheEntry parent) {
                return new ReadGraphImpl(null, parent, processor);
        }
+       
+       public ReadGraphImpl forSyncExecute() {
+               return withParent(null, null, true);
+       }
 
     public static ReadGraphImpl create(QueryProcessor support) {
         ReadGraphImpl result = new ReadGraphImpl(null, null, support);
index 075281035a7802842a2b6ab285700b2a22f29d6b..5a7ab819dad27332af584912ef47ba54a7e25a16 100644 (file)
@@ -413,6 +413,16 @@ public class QueryListening {
 
     public void fireListeners(ReadGraphImpl graph) {
 
+        ReadGraphImpl listenerGraph = graph.forSyncExecute();
+        listenerGraph.asyncBarrier.inc();
+        fireListeners_(listenerGraph);
+        listenerGraph.asyncBarrier.dec();
+        listenerGraph.asyncBarrier.waitBarrier(this, listenerGraph);
+
+    }
+
+    private void fireListeners_(ReadGraphImpl graph) {
+
         assert (!processor.updating);
         assert (!processor.cache.collecting);
         assert (!firingListeners);
index 6d9560940be2b1c19b73616c85a2996ee2b65d25..4917bbe257d7cf3970af4c812908d22ef219b388 100644 (file)
@@ -1430,6 +1430,17 @@ final public class QueryProcessor extends AbstractDisposable implements ReadGrap
        
        public void propagateChangesInQueryCache(final ReadGraphImpl graph) {
                
+               ReadGraphImpl syncGraph = graph.forSyncExecute();
+               syncGraph.asyncBarrier.inc();
+               propagateChangesInQueryCache_(syncGraph);
+               syncGraph.asyncBarrier.dec();
+               syncGraph.asyncBarrier.waitBarrier(this, syncGraph);
+
+       }
+
+       
+       public void propagateChangesInQueryCache_(final ReadGraphImpl graph) {
+               
                // Make sure that listening has performed its work
                listening.sync();
 
@@ -1657,7 +1668,8 @@ final public class QueryProcessor extends AbstractDisposable implements ReadGrap
        
        public void invalidateResource(final int resource) {
                if(lastInvalidate == resource) return;
-               scheduledValueUpdates.add(resource);
+               //scheduledValueUpdates.add(resource);
+               scheduledInvalidates.add(resource);
                lastInvalidate = resource;
                cache.dirty = true;
        }
index 1e468f2c3f25e2e3e50cc6487fc02e57d3a7017e..815ba7f154867741bda8fae5b543d5f6a38ce3e1 100644 (file)
@@ -341,10 +341,13 @@ class State {
 
 //                start = System.nanoTime();
                 queryProvider.propagateChangesInQueryCache(graph);
-                ReadGraphImpl listenerGraph = graph.forRecompute(null);
-                listenerGraph.asyncBarrier.inc();
-                queryProvider.listening.fireListeners(listenerGraph);
-                listenerGraph.asyncBarrier.dec();
+                queryProvider.listening.fireListeners(graph);
+
+//                ReadGraphImpl listenerGraph = graph.forRecompute(null);
+//                listenerGraph.asyncBarrier.inc();
+//                queryProvider.listening.fireListeners(listenerGraph);
+//                listenerGraph.asyncBarrier.dec();
+                
 //                duration = System.nanoTime() - start;
 //                System.out.println("performScheduledUpdates " + 1e-9*duration + "s. ");