]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.acorn/src/org/simantics/acorn/lru/LRU.java
Reduce the amount of annoying Retry mutex acquire print
[simantics/platform.git] / bundles / org.simantics.acorn / src / org / simantics / acorn / lru / LRU.java
index 80fec7032940ac3e7a6a1abbebb02325880a8bfc..48b7d4b10a9b34c80e9a68c7b536ef3840e48867 100644 (file)
@@ -556,14 +556,28 @@ public class LRU<MapKey,MapValue extends LRUObject<MapKey, MapValue>> {
                 boolean gotMutex = impl.tryAcquireMutex();
 
                 boolean done = false;
+                int count = 0;
+                long startTime = 0;
                 while (!done) {
 
                     if (gotMutex || borrowMutex) {
                         runWithMutex();
                         done = true;
                     } else {
-                        LOGGER.warn("Retry mutex acquire");
+                        if (count % 10 == 0) {
+                            // Taking too long, sleep for a while.
+                            LOGGER.warn("Retry mutex acquire");
+                            try {
+                                Thread.sleep(10);
+                            } catch (InterruptedException e) {
+                            }
+                        }
                         gotMutex = impl.tryAcquireMutex();
+                        long currentTime = System.currentTimeMillis();
+                        if ((currentTime - startTime) > 10) {
+                            startTime = currentTime;
+                            count++;
+                        }
                     }
 
                 }