From: Tuukka Lehtonen Date: Tue, 10 Apr 2018 20:48:18 +0000 (+0300) Subject: Allow changing DisposingPolicy max queue length X-Git-Tag: v1.43.0~136^2~498 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=2b4124dc54044d664409deba1db29626844ec229;p=simantics%2Fplatform.git Allow changing DisposingPolicy max queue length Needed to suppor preference-configurability of diagram editor background disposal. refs #7863 Change-Id: Ibf9f29dde2c06f5b055bfd42f989368c7573f327 (cherry picked from commit 56a44956cc6cf02ee85b7cfd55c8d3cbfb80a82f) --- diff --git a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/DisposingPolicy.java b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/DisposingPolicy.java index 9e9b7418b..b1778a342 100644 --- a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/DisposingPolicy.java +++ b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/DisposingPolicy.java @@ -15,10 +15,9 @@ public class DisposingPolicy { public static final long DISPOSE_TIME = 30000L; // ms public static final long MIN_DELAY = 200L; // ms - private final int maxQueueLength; - private ArrayDeque disposerQueue = new ArrayDeque(MAX_QUEUE_LENGTH); - private TObjectLongHashMap disposeTime = - new TObjectLongHashMap(MAX_QUEUE_LENGTH); + private volatile int maxQueueLength; + private ArrayDeque disposerQueue; + private TObjectLongHashMap disposeTime; private Runnable currentlyScheduled = null; private Runnable disposeOne = () -> { @@ -35,11 +34,17 @@ public class DisposingPolicy { }; public DisposingPolicy() { - this(MAX_QUEUE_LENGTH); + this(MAX_QUEUE_LENGTH); } public DisposingPolicy(int maxQueueLength) { this.maxQueueLength = maxQueueLength; + this.disposerQueue = new ArrayDeque<>(maxQueueLength); + this.disposeTime = new TObjectLongHashMap<>(maxQueueLength); + } + + public void setMaxQueueLength(int maxQueueLength) { + this.maxQueueLength = maxQueueLength; } private void scheduleDispose() {