harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apetre...@apache.org
Subject svn commit: r532394 - in /harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt: EventDispatchThread.java EventQueueCore.java HeadlessEventDispatchThread.java HeadlessToolkit.java Toolkit.java
Date Wed, 25 Apr 2007 15:42:41 GMT
Author: apetrenko
Date: Wed Apr 25 08:42:40 2007
New Revision: 532394

URL: http://svn.apache.org/viewvc?view=rev&rev=532394
Log:
Patch for HARMONY-3654 "[classlib][awt] Busy waiting in headless event dispatching"

Modified:
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/EventDispatchThread.java
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/EventQueueCore.java
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/HeadlessEventDispatchThread.java
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/HeadlessToolkit.java
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Toolkit.java

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/EventDispatchThread.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/EventDispatchThread.java?view=diff&rev=532394&r1=532393&r2=532394
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/EventDispatchThread.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/EventDispatchThread.java
Wed Apr 25 08:42:40 2007
@@ -96,7 +96,7 @@
         if (!eventQueue.isEmpty() || !nativeQueue.isEmpty()) {
             return;
         }
-        Object eventMonitor = nativeQueue.getEventMonitor();
+        Object eventMonitor = toolkit.getEventMonitor();
         synchronized(eventMonitor) {
             try {
                 eventMonitor.wait();

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/EventQueueCore.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/EventQueueCore.java?view=diff&rev=532394&r1=532393&r2=532394
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/EventQueueCore.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/EventQueueCore.java
Wed Apr 25 08:42:40 2007
@@ -88,15 +88,13 @@
         // TODO: add event coalescing
         if (toolkit != null) {
             toolkit.shutdownWatchdog.setAwtQueueEmpty(false);
-            if (!GraphicsEnvironment.getLocalGraphicsEnvironment().isHeadlessInstance())
{
-                notifyEventMonitor(toolkit);
-            }
+            notifyEventMonitor(toolkit);
         }
         notifyAll();
     }
     
     void notifyEventMonitor(Toolkit t) {
-        Object em = t.getNativeEventQueue().getEventMonitor();
+        Object em = t.getEventMonitor();
         synchronized (em) {
             em.notifyAll();
         }

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/HeadlessEventDispatchThread.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/HeadlessEventDispatchThread.java?view=diff&rev=532394&r1=532393&r2=532394
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/HeadlessEventDispatchThread.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/HeadlessEventDispatchThread.java
Wed Apr 25 08:42:40 2007
@@ -53,11 +53,26 @@
                     toolkit.shutdownWatchdog.setAwtQueueEmpty(true);
                     toolkit.onQueueEmpty();
                     lastPaintTime = System.currentTimeMillis();
+                    waitForAnyEvent();
                 }
             } catch (Throwable t) {
                 t.printStackTrace();
             }
         }
     }   
+
+    private void waitForAnyEvent() {
+        EventQueue eventQueue = toolkit.getSystemEventQueueImpl();
+        if (!eventQueue.isEmpty()) {
+            return;
+        }
+        
+        Object eventMonitor = toolkit.getEventMonitor();
+        synchronized(eventMonitor) {
+            try {
+                eventMonitor.wait();
+            } catch (InterruptedException e) {}
+        }
+    }
 
 }

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/HeadlessToolkit.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/HeadlessToolkit.java?view=diff&rev=532394&r1=532393&r2=532394
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/HeadlessToolkit.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/HeadlessToolkit.java
Wed Apr 25 08:42:40 2007
@@ -39,6 +39,9 @@
 import org.apache.harmony.awt.wtk.WindowFactory;
 
 public final class HeadlessToolkit extends ToolkitImpl {
+
+    private class EventMonitor {}
+    private final Object eventMonitor = new EventMonitor();
     
     @Override
     protected ButtonPeer createButton(Button a0) throws HeadlessException {
@@ -156,6 +159,11 @@
     @Override
     public ColorModel getColorModel() throws HeadlessException {
         throw new HeadlessException();
+    }
+
+    @Override
+    public final Object getEventMonitor() {
+        return eventMonitor;
     }
 
     @Override

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Toolkit.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Toolkit.java?view=diff&rev=532394&r1=532393&r2=532394
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Toolkit.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Toolkit.java
Wed Apr 25 08:42:40 2007
@@ -1177,6 +1177,10 @@
         return wtk.getNativeEventQueue();
     }
 
+    Object getEventMonitor(){
+	return wtk.getNativeEventQueue().getEventMonitor();	
+    }
+
     /**
      * Returns a shared instance of implementation of org.apache.harmony.awt.wtk.NativeCursor
      * for current platform for



Mime
View raw message