From d0a7cc0ee9ab6d9080daf105b04583e523a62e87 Mon Sep 17 00:00:00 2001 From: jsimomaa Date: Mon, 19 Jun 2017 08:43:05 +0300 Subject: [PATCH] Reduce the amount of annoying Retry mutex acquire print refs #7175 Change-Id: If9505ec6b79aeee38971f523bb6f1909493abd81 --- .../src/org/simantics/acorn/lru/LRU.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) 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++; + } } } -- 2.43.2