< prev index next >

src/java.desktop/share/classes/sun/awt/SunToolkit.java

Print this page




1487 
1488             bigLoop++;
1489             // Again, for Java events, it was simple to check for new Java
1490             // events by checking event queue, but what if Java events
1491             // resulted in native requests?  Therefor, check native events again.
1492         } while ((syncNativeQueue(timeout) || waitForIdle(timeout)) && bigLoop < MAX_ITERS);
1493     }
1494 
1495     /**
1496      * Platform toolkits need to implement this method to perform the
1497      * sync of the native queue.  The method should wait until native
1498      * requests are processed, all native events are processed and
1499      * corresponding Java events are generated.  Should return
1500      * {@code true} if some events were processed,
1501      * {@code false} otherwise.
1502      */
1503     protected abstract boolean syncNativeQueue(final long timeout);
1504 
1505     private boolean eventDispatched = false;
1506     private boolean queueEmpty = false;
1507     private final Object waitLock = "Wait Lock";
1508 
1509     private boolean isEQEmpty() {
1510         EventQueue queue = getSystemEventQueueImpl();
1511         return AWTAccessor.getEventQueueAccessor().noEvents(queue);
1512     }
1513 
1514     /**
1515      * Waits for the Java event queue to empty.  Ensures that all
1516      * events are processed (including paint events), and that if
1517      * recursive events were generated, they are also processed.
1518      * Should return {@code true} if more processing is
1519      * necessary, {@code false} otherwise.
1520      */
1521     @SuppressWarnings("serial")
1522     protected final boolean waitForIdle(final long timeout) {
1523         flushPendingEvents();
1524         boolean queueWasEmpty = isEQEmpty();
1525         queueEmpty = false;
1526         eventDispatched = false;
1527         synchronized(waitLock) {




1487 
1488             bigLoop++;
1489             // Again, for Java events, it was simple to check for new Java
1490             // events by checking event queue, but what if Java events
1491             // resulted in native requests?  Therefor, check native events again.
1492         } while ((syncNativeQueue(timeout) || waitForIdle(timeout)) && bigLoop < MAX_ITERS);
1493     }
1494 
1495     /**
1496      * Platform toolkits need to implement this method to perform the
1497      * sync of the native queue.  The method should wait until native
1498      * requests are processed, all native events are processed and
1499      * corresponding Java events are generated.  Should return
1500      * {@code true} if some events were processed,
1501      * {@code false} otherwise.
1502      */
1503     protected abstract boolean syncNativeQueue(final long timeout);
1504 
1505     private boolean eventDispatched = false;
1506     private boolean queueEmpty = false;
1507     private final Object waitLock = new Object();
1508 
1509     private boolean isEQEmpty() {
1510         EventQueue queue = getSystemEventQueueImpl();
1511         return AWTAccessor.getEventQueueAccessor().noEvents(queue);
1512     }
1513 
1514     /**
1515      * Waits for the Java event queue to empty.  Ensures that all
1516      * events are processed (including paint events), and that if
1517      * recursive events were generated, they are also processed.
1518      * Should return {@code true} if more processing is
1519      * necessary, {@code false} otherwise.
1520      */
1521     @SuppressWarnings("serial")
1522     protected final boolean waitForIdle(final long timeout) {
1523         flushPendingEvents();
1524         boolean queueWasEmpty = isEQEmpty();
1525         queueEmpty = false;
1526         eventDispatched = false;
1527         synchronized(waitLock) {


< prev index next >