LaterInvocator: when leaving a modal state, run all the associated runnables

This commit is contained in:
peter
2015-04-07 14:58:19 +02:00
parent 132dbde6ad
commit ce42137fcd
@@ -83,7 +83,7 @@ public class LaterInvocator {
private static final List<Object> ourModalEntities = ContainerUtil.createLockFreeCopyOnWriteList();
private static final List<RunnableInfo> ourQueue = new ArrayList<RunnableInfo>(); //protected by LOCK
private static volatile int ourQueueSkipCount = 0; // optimization
private static final Runnable ourFlushQueueRunnable = new FlushQueue();
private static final FlushQueue ourFlushQueueRunnable = new FlushQueue();
private static final Stack<AWTEvent> ourEventStack = new Stack<AWTEvent>(); // guarded by RUN_LOCK
@@ -189,6 +189,9 @@ public class LaterInvocator {
LOG.debug("leaveModal:" + modalEntity);
}
//noinspection StatementWithEmptyBody
while (ourFlushQueueRunnable.runNextEvent());
ourModalityStateMulticaster.getMulticaster().beforeModalityStateChanged(false);
boolean removed = ourModalEntities.remove(modalEntity);
@@ -308,12 +311,17 @@ public class LaterInvocator {
private static final Object RUN_LOCK = new Object();
private static class FlushQueue implements Runnable {
private RunnableInfo myLastInfo;
@SuppressWarnings("FieldAccessedSynchronizedAndUnsynchronized") private RunnableInfo myLastInfo;
@Override
public void run() {
FLUSHER_SCHEDULED.set(false);
if (runNextEvent()) {
requestFlush();
}
}
private boolean runNextEvent() {
final RunnableInfo lastInfo = getNextEvent(true);
myLastInfo = lastInfo;
@@ -338,9 +346,8 @@ public class LaterInvocator {
if (!DEBUG) myLastInfo = null;
}
}
requestFlush();
}
return lastInfo != null;
}
@Override