You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Sergey Dmitriev (JIRA)" <ji...@apache.org> on 2007/04/15 12:32:15 UTC

[jira] Created: (HARMONY-3654) Busy waiting in headless event dispatching

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.


[jira] Updated: (HARMONY-3654) [classlib][awt] Busy waiting in headless event dispatching

Posted by "Dmitriy Matveev (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-3654?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dmitriy Matveev updated HARMONY-3654:
-------------------------------------

    Attachment: headlessFix.patch

The patch adds EventMonitor for Toolkit and HeadlessToolkit classes, adds waitForAnyEvent() for HeadlessEventDispatchThread class for fixing this bug and removes unnecessary checking of headless instance in EventQueueCore class.

> [classlib][awt] 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
>         Attachments: headlessFix.patch
>
>
> 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.


[jira] Commented: (HARMONY-3654) [classlib][awt] Busy waiting in headless event dispatching

Posted by "Sergey Dmitriev (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-3654?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12494006 ] 

Sergey Dmitriev commented on HARMONY-3654:
------------------------------------------

Yep, busy waiting seems to disappear. Thanks.

> [classlib][awt] 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
>         Assigned To: Alexey Petrenko
>         Attachments: headlessFix.patch
>
>
> 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.


[jira] Resolved: (HARMONY-3654) [classlib][awt] Busy waiting in headless event dispatching

Posted by "Alexey Petrenko (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-3654?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Alexey Petrenko resolved HARMONY-3654.
--------------------------------------

    Resolution: Fixed

The patch has been applied.
Please verify.

> [classlib][awt] 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
>         Assigned To: Alexey Petrenko
>         Attachments: headlessFix.patch
>
>
> 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.


[jira] Updated: (HARMONY-3654) [classlib][awt] Busy waiting in headless event dispatching

Posted by "Alexey Petrenko (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-3654?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Alexey Petrenko updated HARMONY-3654:
-------------------------------------

    Summary: [classlib][awt] Busy waiting in headless event dispatching  (was: Busy waiting in headless event dispatching)

> [classlib][awt] 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.


[jira] Assigned: (HARMONY-3654) [classlib][awt] Busy waiting in headless event dispatching

Posted by "Alexey Petrenko (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-3654?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Alexey Petrenko reassigned HARMONY-3654:
----------------------------------------

    Assignee: Alexey Petrenko

> [classlib][awt] 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
>         Assigned To: Alexey Petrenko
>         Attachments: headlessFix.patch
>
>
> 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.


[jira] Closed: (HARMONY-3654) [classlib][awt] Busy waiting in headless event dispatching

Posted by "Alexey Petrenko (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-3654?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Alexey Petrenko closed HARMONY-3654.
------------------------------------


> [classlib][awt] 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
>         Assigned To: Alexey Petrenko
>         Attachments: headlessFix.patch
>
>
> 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.