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 = () -> {
};
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() {