]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.acorn/src/org/simantics/acorn/MainProgram.java
Corrected lifetime of clusters from Integer.MAX_VALUE to Long.MAX_VALUE
[simantics/platform.git] / bundles / org.simantics.acorn / src / org / simantics / acorn / MainProgram.java
index c69c7bea6fe7957bf3c408256a6d9f5cbfed16e4..b5ba2471b486b10ce91f169c2797cc0673ddc276 100644 (file)
@@ -128,7 +128,7 @@ public class MainProgram implements Runnable, Closeable {
                                                try {
                                                        long start = System.nanoTime();
                                                        mutex.release();
-                                                       MainProgram.this.wait(5000);
+                                                       MainProgram.this.wait(5000); // wake up when new operations are scheduled or the last operation is committed  
                                                        mutex.acquire();
                                                        if (!alive)
                                                                break main;
@@ -300,19 +300,13 @@ public class MainProgram implements Runnable, Closeable {
        private void swapChunks() throws AcornAccessVerificationException, IllegalAcornStateException {
 
                // Cache chunks during update operations
-               boolean written = clusters.streamLRU.swap(Integer.MAX_VALUE, CHUNK_CACHE_SIZE);
-               while(written) {
-                       written = clusters.streamLRU.swap(Integer.MAX_VALUE, CHUNK_CACHE_SIZE);
-               }
+               while(clusters.streamLRU.swap(Long.MAX_VALUE, CHUNK_CACHE_SIZE));
        }
 
        private void swapCS() throws AcornAccessVerificationException, IllegalAcornStateException {
 
                // Cache chunks during update operations
-               boolean written = clusters.csLRU.swap(Integer.MAX_VALUE, CHUNK_CACHE_SIZE);
-               while(written) {
-                       written = clusters.csLRU.swap(Integer.MAX_VALUE, CHUNK_CACHE_SIZE);
-               }
+               while(clusters.csLRU.swap(Long.MAX_VALUE, CHUNK_CACHE_SIZE));
        }
 
        public synchronized void committed() {
@@ -322,7 +316,10 @@ public class MainProgram implements Runnable, Closeable {
             LOGGER.error("Trying to commit operation after MainProgram is closed! Operation is " + last);
 //          return;
         }
-               if(last != null) last.commit();
+               if(last != null) {
+                       last.commit();
+                       notifyAll();
+               }
 
        }