]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.acorn/src/org/simantics/acorn/MainProgram.java
MainProgram polls nanoTime too often
[simantics/platform.git] / bundles / org.simantics.acorn / src / org / simantics / acorn / MainProgram.java
index 8dea16d7fe73a5cc0234a6e00998ad964f184513..1e4b5cbac508623fff9fd9d5017043818ce1ee42 100644 (file)
@@ -61,6 +61,7 @@ public class MainProgram implements Runnable, Closeable {
                }
        }
 
+       @SuppressWarnings("unchecked")
        MainProgram(GraphClientImpl2 client, ClusterManager clusters) {
 
                this.client = client;
@@ -101,17 +102,15 @@ public class MainProgram implements Runnable, Closeable {
 
                                if(updates.isEmpty()) {
 
-                                       long start = System.nanoTime();
-
-                                       operationQueue.waitFor();
+                                       long duration = operationQueue.waitFor();
 
                                        if (!alive)
                                                break main;
 
-                                       long duration = System.nanoTime()-start;
                                        if(duration > 4000000000L) {
                                                checkIdle();
                                        }
+                                       
                                }
 
 //                             long sss = System.nanoTime();
@@ -128,7 +127,7 @@ public class MainProgram implements Runnable, Closeable {
                                try {
                                        swapChunks();
                                } catch (AcornAccessVerificationException | IllegalAcornStateException e) {
-                                   e.printStackTrace();
+                                       LOGGER.error("cluster chunk swapping failed", e);
                                } finally {
                                        clusters.streamLRU.releaseMutex();
                                }
@@ -146,7 +145,7 @@ public class MainProgram implements Runnable, Closeable {
                        }
 
                } catch (Throwable t) {
-                       t.printStackTrace();
+                       LOGGER.error("FATAL: MainProgram died unexpectedly", t);
                } finally {
                        deathBarrier.release();
                }
@@ -356,7 +355,7 @@ public class MainProgram implements Runnable, Closeable {
                 executor.awaitTermination(500, TimeUnit.MILLISECONDS);
                 clusterUpdateThreads[i] = null;
             } catch (InterruptedException e) {
-                e.printStackTrace();
+                LOGGER.error("clusterUpdateThread[{}] termination interrupted", i, e);
             }
         }
     }