]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/QueryCacheBase.java
Working towards multiple readers.
[simantics/platform.git] / bundles / org.simantics.db.impl / src / org / simantics / db / impl / query / QueryCacheBase.java
index 2d3c92d8242ed3259ea0518520262666cbabd423..5a06ded0be4ce2915a5c3914ba1286b95f2dfce5 100644 (file)
@@ -7,6 +7,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
 
 import org.simantics.db.AsyncReadGraph;
 import org.simantics.db.ObjectResourceIdMap;
+import org.simantics.db.ReadGraph;
 import org.simantics.db.RelationInfo;
 import org.simantics.db.common.utils.Logger;
 import org.simantics.db.exception.DatabaseException;
@@ -19,6 +20,7 @@ import org.simantics.db.procedure.AsyncProcedure;
 import org.simantics.db.procedure.Listener;
 import org.simantics.db.procedure.ListenerBase;
 import org.simantics.db.procedure.Procedure;
+import org.simantics.db.procedure.SyncMultiProcedure;
 import org.simantics.db.request.AsyncMultiRead;
 import org.simantics.db.request.AsyncRead;
 import org.simantics.db.request.ExternalRead;
@@ -320,15 +322,15 @@ public class QueryCacheBase {
 
                ReadGraphImpl queryGraph = parentGraph.withParent(entry_);
 
-               AsyncMultiReadEntry entry = (AsyncMultiReadEntry)entry_;
-               AsyncMultiProcedure<T> procedure = (AsyncMultiProcedure<T>)procedure_;
+               MultiReadEntry entry = (MultiReadEntry)entry_;
+               SyncMultiProcedure<T> procedure = (SyncMultiProcedure<T>)procedure_;
 
                try {
 
-                       query.perform(queryGraph, new AsyncMultiProcedure<T>() {
+                       query.perform(queryGraph, new SyncMultiProcedure<T>() {
 
                                @Override
-                               public void execute(AsyncReadGraph graph, T result) {
+                               public void execute(ReadGraph graph, T result) {
                                        ReadGraphImpl impl = (ReadGraphImpl)graph;
                                        entry.addOrSet(result);
                                        try {
@@ -339,7 +341,7 @@ public class QueryCacheBase {
                                }
 
                                @Override
-                               public void finished(AsyncReadGraph graph) {
+                               public void finished(ReadGraph graph) {
                                        ReadGraphImpl impl = (ReadGraphImpl)graph;
                                        entry.finish(parentGraph);
                                        try {
@@ -350,9 +352,9 @@ public class QueryCacheBase {
                                }
 
                                @Override
-                               public void exception(AsyncReadGraph graph, Throwable t) {
+                               public void exception(ReadGraph graph, Throwable t) {
                                        ReadGraphImpl impl = (ReadGraphImpl)graph;
-                                       entry.except(parentGraph, t);
+                                       entry.except((DatabaseException)t);
                                        try {
                                                procedure.exception(parentGraph, t);
                                        } catch (Throwable t2) {
@@ -890,6 +892,23 @@ public class QueryCacheBase {
                
        }; 
 
+    protected static SyncMultiProcedure<Object> emptySyncMultiProcedure = new SyncMultiProcedure<Object>() {
+
+               @Override
+               public void execute(ReadGraph graph, Object result) {
+               }
+
+               @Override
+               public void finished(ReadGraph graph) {
+               }
+
+               @Override
+               public void exception(ReadGraph graph, Throwable throwable) {
+               }
+
+               
+       }; 
+
        protected static InternalProcedure<IntSet> emptyProcedureTypes = emptyIntSetProcedure;
     protected static InternalProcedure<IntSet> emptyProcedureSuperTypes = emptyIntSetProcedure;
     protected static InternalProcedure<IntSet> emptyProcedureTypeHierarchy = emptyIntSetProcedure;
@@ -916,7 +935,7 @@ public class QueryCacheBase {
 
     protected static AsyncProcedure emptyProcedureReadEntry = emptyAsyncProcedure;
     protected static AsyncProcedure emptyProcedureAsyncReadEntry = emptyAsyncProcedure;
-    protected static AsyncMultiProcedure emptyProcedureMultiReadEntry = emptyAsyncMultiProcedure;
+    protected static SyncMultiProcedure emptyProcedureMultiReadEntry = emptySyncMultiProcedure;
     protected static AsyncMultiProcedure emptyProcedureAsyncMultiReadEntry = emptyAsyncMultiProcedure;
     protected static AsyncProcedure emptyProcedureExternalReadEntry = emptyAsyncProcedure;