]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/AsyncReadEntry.java
Fixes based on feedback
[simantics/platform.git] / bundles / org.simantics.db.impl / src / org / simantics / db / impl / query / AsyncReadEntry.java
index e6d42750d37b9caf62196bd50c043b802093d7e6..f409b40c8c330069023ede4686c6363ba76ae948 100644 (file)
@@ -13,7 +13,6 @@ package org.simantics.db.impl.query;
 
 import org.simantics.db.AsyncReadGraph;
 import org.simantics.db.exception.DatabaseException;
-import org.simantics.db.exception.RuntimeDatabaseException;
 import org.simantics.db.impl.BlockingAsyncProcedure;
 import org.simantics.db.impl.DebugPolicy;
 import org.simantics.db.impl.graph.AsyncBarrierImpl;
@@ -72,7 +71,7 @@ final public class AsyncReadEntry<T> extends CacheEntryBase<AsyncProcedure<T>> i
 
                 try {
 
-                    BlockingAsyncProcedure<T> proc = new BlockingAsyncProcedure<>(graph, new AsyncProcedure<T>() {
+                    BlockingAsyncProcedure<T> proc = new BlockingAsyncProcedure<>(graph.asyncBarrier, graph, new AsyncProcedure<T>() {
 
                         @Override
                         public void execute(AsyncReadGraph graph, T result) {
@@ -154,10 +153,11 @@ final public class AsyncReadEntry<T> extends CacheEntryBase<AsyncProcedure<T>> i
 
         ReadGraphImpl queryGraph = graph.withParent(entry);
         
-        BlockingAsyncProcedure<T> proc = new BlockingAsyncProcedure<>(queryGraph, null, request);
+        BlockingAsyncProcedure<T> proc = new BlockingAsyncProcedure<>(queryGraph.asyncBarrier, graph, null, request);
         
         class AsyncTask extends SessionTask {
 
+               int counter = 0;
             T result;
             DatabaseException exception;
             
@@ -181,9 +181,21 @@ final public class AsyncReadEntry<T> extends CacheEntryBase<AsyncProcedure<T>> i
                         exception = dbe;
                     } finally {
                         if (entry != null)
-                            entry.performFromCache(queryGraph, procedure_);
+                            entry.performFromCache(graph, procedure_);
                     }
                 } else {
+                       if(counter++ > 10000) {
+                               AsyncBarrierImpl.printReverse(queryGraph.asyncBarrier, 2);
+                               AsyncBarrierImpl caller = queryGraph.asyncBarrier.caller;
+                               while(caller != null) {
+                                       System.err.println("called by " + AsyncBarrierImpl.report(caller));
+                                       caller = caller.caller;
+                               }
+                               for(AsyncBarrierImpl ab : AsyncBarrierImpl.debuggerMap.keySet()) {
+                               AsyncBarrierImpl.printReverse(ab, 2);
+                               }
+                               throw new IllegalStateException("Eternal loop in queries.");
+                       }
                     graph.processor.schedule(this);            
                 }
             }