]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/CodeGen.java
Trying to remove synchronization problems
[simantics/platform.git] / bundles / org.simantics.db.impl / src / org / simantics / db / impl / query / CodeGen.java
index cd540eaadbf59a63c3e450999254ead404a9cefe..3d5f14ac493603d800102438e65ff5751786e8ec 100644 (file)
@@ -14,8 +14,6 @@ public class CodeGen {
        
        int indent = 4;
        
-
-       
        String[] signatureR1RelationInfo = { "int r", "r", "keyR", "long", "InternalProcedure<RelationInfo>", "entry.id" };
        String[] signatureR1Bytes = { "int r", "r", "keyR", "long", "InternalProcedure<byte[]>", "entry.id" };
        String[] signatureR1IntSet = { "int r", "r", "keyR", "long", "InternalProcedure<IntSet>", "entry.id" };
@@ -54,7 +52,7 @@ public class CodeGen {
                        line(content, "        return;");
                        line(content, "    }");
                }
-               line(content, "    " + clazz + " entry = (" + clazz + ")cache.getOrCreate" + clazz + "(graph, " + signature[1] + (genAsync ? ", isSync" : "") + ");");
+               line(content, "    " + clazz + " entry = (" + clazz + ")cache.getOrCreate" + clazz + "(graph.processor, " + signature[1] + (genAsync ? ", isSync" : "") + ");");
                if(genAsync) {
                        line(content, "    if(entry == null) {");
                        line(content, "        graph.processor.schedule(new SessionTask(false) {");
@@ -102,7 +100,7 @@ public class CodeGen {
                
                String lower = Character.toLowerCase(clazz.charAt(0)) + clazz.substring(1);
                
-               line(content, "" + clazz + " getOrCreate" + clazz + "(ReadGraphImpl graph, " + signature[0] + (genAsync ? ", boolean isSync" : "") + ") throws DatabaseException {");
+               line(content, "" + clazz + " getOrCreate" + clazz + "(QueryProcessor processor, " + signature[0] + (genAsync ? ", boolean isSync" : "") + ") throws DatabaseException {");
                line(content, "    " + clazz + " existing = null;");
                line(content, "    synchronized(" + lower + "Map) {");
                line(content, "        existing = (" + clazz + ")" + lower + "Map.get(" + signature[1] + ");");
@@ -121,11 +119,11 @@ public class CodeGen {
                line(content, "    }");
                if(genAsync) {
                        line(content, "    if(existing.isPending()) {");
-                       line(content, "      if(isSync) waitPending(graph, existing);");
+                       line(content, "      if(isSync) waitPending(processor, existing);");
                        line(content, "      else return null;");
                        line(content, "    }");
                } else {
-                       line(content, "    if(existing.isPending()) waitPending(graph, existing);");
+                       line(content, "    if(existing.isPending()) waitPending(processor, existing);");
                }
                line(content, "    return existing;");
                line(content, "}");
@@ -188,15 +186,14 @@ public class CodeGen {
                     generateQuery(content, "ReadEntry", signatureRead, true, true);
                     generateQuery(content, "AsyncReadEntry", signatureAsyncRead, true, true);
                     generateQuery(content, "Types", signatureR1IntSet, true, false);
-                    //generateQuery(content, "NamespaceIndex", signatureID2, true);
                     generateQuery(content, "ChildMap", signatureChildMap, true, false);
+                    generateQuery(content, "TypeHierarchy", signatureR1IntSet, true, false);
+                    generateQuery(content, "SuperTypes", signatureR1IntSet, true, false);
+                    generateQuery(content, "SuperRelations", signatureR1IntSet, true, false);
 
-                    generateQuery(content, "AssertedStatements", signatureR2TIP, false, false);
                     generateQuery(content, "AssertedPredicates", signatureR1IP, false, false);
+                    generateQuery(content, "AssertedStatements", signatureR2TIP, false, false);
                     generateQuery(content, "DirectSuperRelations", signatureR1IP, false, false);
-                    generateQuery(content, "SuperTypes", signatureR1IntSet, false, false);
-                    generateQuery(content, "TypeHierarchy", signatureR1IntSet, false, false);
-                    generateQuery(content, "SuperRelations", signatureR1IntSet, false, false);
                     generateQuery(content, "MultiReadEntry", signatureMultiRead, false, false);
                     generateQuery(content, "AsyncMultiReadEntry", signatureAsyncMultiRead, false, false);
                     generateQuery(content, "ExternalReadEntry", signatureExternalRead, false, false);