|
1 | 1 | /*******************************************************************************
|
2 |
| - * Copyright (c) 2000, 2024 IBM Corporation and others. |
| 2 | + * Copyright (c) 2000, 2025 IBM Corporation and others. |
3 | 3 | *
|
4 | 4 | * This program and the accompanying materials are made available under the
|
5 | 5 | * terms of the Eclipse Public License 2.0 which is available at
|
@@ -57,26 +57,9 @@ public void run() {
|
57 | 57 |
|
58 | 58 | private boolean updating;
|
59 | 59 | private boolean validating;
|
60 |
| - private RunnableChain afterUpdate; |
| 60 | + private List<Runnable> afterUpdate = new ArrayList<>(); |
61 | 61 | private int refreshRate = -1;
|
62 | 62 |
|
63 |
| - private static class RunnableChain { |
64 |
| - RunnableChain next; |
65 |
| - Runnable run; |
66 |
| - |
67 |
| - RunnableChain(Runnable run, RunnableChain next) { |
68 |
| - this.run = run; |
69 |
| - this.next = next; |
70 |
| - } |
71 |
| - |
72 |
| - void run() { |
73 |
| - if (next != null) { |
74 |
| - next.run(); |
75 |
| - } |
76 |
| - run.run(); |
77 |
| - } |
78 |
| - } |
79 |
| - |
80 | 63 | /**
|
81 | 64 | * Empty constructor.
|
82 | 65 | */
|
@@ -195,11 +178,11 @@ public synchronized void performUpdate() {
|
195 | 178 | performValidation();
|
196 | 179 | updateQueued = false;
|
197 | 180 | repairDamage();
|
198 |
| - if (afterUpdate != null) { |
199 |
| - RunnableChain chain = afterUpdate; |
200 |
| - afterUpdate = null; |
201 |
| - chain.run(); // chain may queue additional Runnable. |
202 |
| - if (afterUpdate != null) { |
| 181 | + if (!afterUpdate.isEmpty()) { |
| 182 | + List<Runnable> chain = afterUpdate; |
| 183 | + afterUpdate = new ArrayList<>(); |
| 184 | + chain.forEach(Runnable::run); // chain may queue additional Runnable. |
| 185 | + if (!afterUpdate.isEmpty()) { |
203 | 186 | queueWork();
|
204 | 187 | }
|
205 | 188 | }
|
@@ -330,7 +313,7 @@ protected void repairDamage() {
|
330 | 313 | */
|
331 | 314 | @Override
|
332 | 315 | public synchronized void runWithUpdate(Runnable runnable) {
|
333 |
| - afterUpdate = new RunnableChain(runnable, afterUpdate); |
| 316 | + afterUpdate.add(runnable); |
334 | 317 | if (!updating) {
|
335 | 318 | queueWork();
|
336 | 319 | }
|
|
0 commit comments