]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/AsyncReadEntry.java
Fix livelock situation in QueryProcessor
[simantics/platform.git] / bundles / org.simantics.db.impl / src / org / simantics / db / impl / query / AsyncReadEntry.java
index 72582ee605802bfe32fac38d10119f6200602586..e13ecab72cd0819f71c3c337af62ad242db709c2 100644 (file)
@@ -169,7 +169,14 @@ final public class AsyncReadEntry<T> extends CacheEntryBase<AsyncProcedure<T>> i
             DatabaseException exception;
             
             public AsyncTask(ReadGraphImpl graph) {
+                this(graph, 1);
+            }
+
+            public AsyncTask(ReadGraphImpl graph, int pos) {
                 super(graph);
+                this.position = pos;
+                if(this.position < 1024)
+                    this.position *= 2;
             }
 
             @Override
@@ -213,10 +220,15 @@ final public class AsyncReadEntry<T> extends CacheEntryBase<AsyncProcedure<T>> i
                         }
                         throw new IllegalStateException("Eternal loop in queries.");
                     }
-                    graph.processor.schedule(new AsyncTask(graph));
+                    graph.processor.scheduleLater(new AsyncTask(graph, position));
                 }
             }
             
+            @Override
+            public boolean maybeReady() {
+               return proc.isDone();
+            }
+            
         }
 
         try {
@@ -230,7 +242,7 @@ final public class AsyncReadEntry<T> extends CacheEntryBase<AsyncProcedure<T>> i
         if(needsToBlock) task.run(0);
         else if (proc.isDone()) task.run(0);
         else  {
-            graph.processor.schedule(task);
+            graph.processor.scheduleLater(task);
             return null;
         }