harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sergey Dmitriev (JIRA)" <j...@apache.org>
Subject [jira] Created: (HARMONY-3654) Busy waiting in headless event dispatching
Date Sun, 15 Apr 2007 10:32:15 GMT
Busy waiting in headless event dispatching
------------------------------------------

                 Key: HARMONY-3654
                 URL: https://issues.apache.org/jira/browse/HARMONY-3654
             Project: Harmony
          Issue Type: Bug
          Components: Classlib
            Reporter: Sergey Dmitriev


Recently I've found that we have a busy waiting in classlib:

modules/awt/src/main/java/common/java/awt/HeadlessEventDispatchThread.java. Namely:

    void runModalLoop(ModalContext context) {
        long lastPaintTime = System.currentTimeMillis();
        while (!shutdownPending && (context == null || context.isModalLoopRunning()))
{
            try {
                EventQueue eventQueue = toolkit.getSystemEventQueueImpl();
                toolkit.shutdownWatchdog.setNativeQueueEmpty(true);

                AWTEvent ae = eventQueue.getNextEventNoWait(); // NO WAIT
                if (ae != null) {
                    eventQueue.dispatchEvent(ae);
                    long curTime = System.currentTimeMillis();
                    if (curTime - lastPaintTime > 10) {
                        toolkit.onQueueEmpty();
                        lastPaintTime = System.currentTimeMillis();
                    }
                } else {
                    toolkit.shutdownWatchdog.setAwtQueueEmpty(true);
                    toolkit.onQueueEmpty(); // NO WAITING UNDERLIES
                    lastPaintTime = System.currentTimeMillis();
                }
            } catch (Throwable t) {
                t.printStackTrace();
            }
        }
    }

It would be cool to lighten the whole thread. Java.awt.EventDispatchThread implementation
can be taken as a start point.



-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message