X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.acorn%2Fsrc%2Forg%2Fsimantics%2Facorn%2Flru%2FLRU.java;h=48b7d4b10a9b34c80e9a68c7b536ef3840e48867;hp=80fec7032940ac3e7a6a1abbebb02325880a8bfc;hb=d0a7cc0ee9ab6d9080daf105b04583e523a62e87;hpb=e1ec84d6bf6180c486a7c63ae9379d9f32577a23 diff --git a/bundles/org.simantics.acorn/src/org/simantics/acorn/lru/LRU.java b/bundles/org.simantics.acorn/src/org/simantics/acorn/lru/LRU.java index 80fec7032..48b7d4b10 100644 --- a/bundles/org.simantics.acorn/src/org/simantics/acorn/lru/LRU.java +++ b/bundles/org.simantics.acorn/src/org/simantics/acorn/lru/LRU.java @@ -556,14 +556,28 @@ public class LRU> { 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++; + } } }