]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
MainProgram polls nanoTime too often 65/3765/1
authorAntti Villberg <antti.villberg@semantum.fi>
Thu, 9 Jan 2020 11:59:08 +0000 (13:59 +0200)
committerAntti Villberg <antti.villberg@semantum.fi>
Thu, 9 Jan 2020 11:59:08 +0000 (13:59 +0200)
gitlab #440

Change-Id: I9d6b1514907682b990ae21588ced70b35f5ed6f5

bundles/org.simantics.acorn/src/org/simantics/acorn/MainProgram.java
bundles/org.simantics.acorn/src/org/simantics/acorn/OperationQueue.java

index ec4d56c211ad54640d6d6f429d8847e8d6bf7760..1e4b5cbac508623fff9fd9d5017043818ce1ee42 100644 (file)
@@ -102,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();
index 7a9d8aba23f1b714d190a92552f879066775a94e..a85aa882930446b6214e4bd5116b8e3358233930 100644 (file)
@@ -157,18 +157,20 @@ class OperationQueue {
         * Wake up when new operations are scheduled or the last operation is committed
         * Called by MainProgram thread
         */
-       synchronized void waitFor() {
+       synchronized long waitFor() {
 
                mainProgram.assertMainProgramThread();
 
                // One last check within the monitor 
-               if(!operations.isEmpty() || !tasks.isEmpty()) return;
+               if(!operations.isEmpty() || !tasks.isEmpty()) return 0;
 
+               long start = System.nanoTime();
                try {
                        wait(5000);
                } catch (InterruptedException e) {
                        LOGGER.error("Unexpected interruption", e);
                }
+               return System.nanoTime() - start;
 
        }