]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/QueryCacheBase.java
Attempt to fix regressions in new code base
[simantics/platform.git] / bundles / org.simantics.db.impl / src / org / simantics / db / impl / query / QueryCacheBase.java
index b3d1c5f8836dcfdc82637dc01fec5bd3dfebce82..d7a235fc813d4f302e719bb66647cd2cef972d91 100644 (file)
@@ -637,18 +637,16 @@ public class QueryCacheBase {
                }
        }
 
-       public static void waitPending(QueryProcessor processor, CacheEntry entry) throws DatabaseException {
+       public static void waitPending(ReadGraphImpl graph, CacheEntry entry) throws DatabaseException {
 
                int counter = 0;
                while(entry.isPending()) {
                        try {
-                               SessionTask task = null;//processor.getOwnTask(processor.thread.get());
-                               if(task != null) {
-                                       task.run(processor.thread.get());
-                               } else {
+                           boolean performed = graph.performPending();
+                           if(!performed) {
                                        Thread.sleep(1);
                                        counter++;
-                                       if(counter > 5000) {
+                                       if(counter > 30000) {
                                                CacheEntryBase base = ((CacheEntryBase)entry);
 //                                             if(base.created != null) {
 //                                                     System.err.println("created:");
@@ -662,8 +660,8 @@ public class QueryCacheBase {
 //                                                     System.err.println("ready:");
 //                                                     base.ready.printStackTrace();
 //                                             }
-                                               new Exception("Timeout waiting for request to complete: " + entry.getOriginalRequest().toString()).printStackTrace();
-                                               throw new DatabaseException("Timeout waiting for request to complete.");
+                                               new Exception("Timeout waiting for request to complete: " + entry.getOriginalRequest()).printStackTrace();
+                                               throw new DatabaseException("Timeout waiting for request to complete." +  entry.getOriginalRequest());
                                                //System.err.println("asd");
                                                //base.getQuery().recompute(null, null, entry);
                                        }
@@ -1129,15 +1127,11 @@ public class QueryCacheBase {
        }
 
        public static <T> T resultReadEntry(ReadGraphImpl graph, Read r, CacheEntry parent, ListenerBase listener, AsyncProcedure<T> procedure) throws DatabaseException {
-               AsyncProcedureWrapper<T> wrap = new AsyncProcedureWrapper<>(procedure);
-               QueryCache.runnerReadEntry(graph, r, parent, listener, wrap, true);
-               return wrap.get();
+               return (T)QueryCache.runnerReadEntry(graph, r, parent, listener, procedure, true);
        }
 
        public static <T> T resultAsyncReadEntry(ReadGraphImpl graph, AsyncRead r, CacheEntry parent, ListenerBase listener, AsyncProcedure<T> procedure) throws DatabaseException {
-               AsyncProcedureWrapper<T> wrap = new AsyncProcedureWrapper<>(procedure);
-               QueryCache.runnerAsyncReadEntry(graph, r, parent, listener, wrap, true);
-               return wrap.get();
+               return (T)QueryCache.runnerAsyncReadEntry(graph, r, parent, listener, procedure, true);
        }
 
        public static byte[] resultValueQuery(ReadGraphImpl graph, int r, CacheEntry parent, ListenerBase listener) throws DatabaseException {