]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Allow changing DisposingPolicy max queue length 03/1703/1
authorTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Tue, 10 Apr 2018 20:48:18 +0000 (23:48 +0300)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Tue, 10 Apr 2018 20:48:18 +0000 (23:48 +0300)
Needed to suppor preference-configurability of diagram editor background
disposal.

refs #7863

Change-Id: Ibf9f29dde2c06f5b055bfd42f989368c7573f327

bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/DisposingPolicy.java

index 9e9b7418bce5cbf069e6d512fa2c9c0a1402e481..b1778a3420cabe8b93259d9935f070761890a27e 100644 (file)
@@ -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<Runnable> disposerQueue = new ArrayDeque<Runnable>(MAX_QUEUE_LENGTH);
-    private TObjectLongHashMap<Runnable> disposeTime =
-            new TObjectLongHashMap<Runnable>(MAX_QUEUE_LENGTH);
+    private volatile int maxQueueLength;
+    private ArrayDeque<Runnable> disposerQueue;
+    private TObjectLongHashMap<Runnable> 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() {