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=690ba426f209afd52035ac875530b1f7e2b3d763;hb=d0a7cc0ee9ab6d9080daf105b04583e523a62e87;hpb=ca89ffe386060acd0915580c60b2ab6fde36a5db 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 690ba426f..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,18 +556,28 @@ public class LRU> { boolean gotMutex = impl.tryAcquireMutex(); boolean done = false; - // TODO: fix this properly pleease int count = 0; + long startTime = 0; while (!done) { if (gotMutex || borrowMutex) { runWithMutex(); done = true; } else { - if (count % 100 == 0) + 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(); - count++; + long currentTime = System.currentTimeMillis(); + if ((currentTime - startTime) > 10) { + startTime = currentTime; + count++; + } } }