]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db.impl/src/org/simantics/db/impl/graph/BarrierTracing.java
Add possibility to bookkeep barrier tracing with env var
[simantics/platform.git] / bundles / org.simantics.db.impl / src / org / simantics / db / impl / graph / BarrierTracing.java
index 2433b897f888d15044e135433aa444fb48f498d0..3c9b7a011adf71ffa3e48d94293bd9673def5505 100644 (file)
@@ -11,7 +11,12 @@ import org.simantics.db.impl.query.QueryProcessor.SessionTask;
 
 public class BarrierTracing {
 
-    public static final boolean BOOKKEEPING = false;
+    private static final String KEY = "SIMANTICS_DB_IMPL_BARRIER_TRACING";
+
+    public static final boolean BOOKKEEPING = Boolean.parseBoolean(
+            System.getProperty("org.simantics.db.impl.barrierTracing",
+            System.getenv(KEY) != null ? System.getenv(KEY) : "false")
+        );
     static final boolean RESTART_GUARD = BOOKKEEPING && false;
 
     public static Map<SessionTask,Exception> tasks = new HashMap<>();
@@ -32,16 +37,10 @@ public class BarrierTracing {
 
     synchronized public static void printBAPS() {
         for(BlockingAsyncProcedure bap : baps.keySet()) {
-            Throwable e = baps.get(bap);
-            System.err.println("BlockingAsyncProcedure");
-            System.err.println("-key: " + bap.key);
-            System.err.println("-queryGraph: " + bap.queryGraph);
-            System.err.println("-callerGraph: " + bap.callerGraph);
-            System.err.println("-procedure: " + bap.procedure);
-            System.err.println("-pendingTaskSupport: " + bap.pendingTaskSupport);
-            System.err.println("-result: " + bap.result);
-            System.err.println("-exception: " + bap.exception);
-            e.printStackTrace();
+            bap.print();
+            Throwable t = baps.get(bap);
+            if(t != null)
+                t.printStackTrace();
         }
     }