src/share/classes/java/awt/WaitDispatchSupport.java

Print this page

        

@@ -163,12 +163,14 @@
     /**
      * @inheritDoc
      */
     @Override
     public boolean enter() {
+        if (log.isLoggable(PlatformLogger.FINE)) {
         log.fine("enter(): blockingEDT=" + keepBlockingEDT.get() +
                  ", blockingCT=" + keepBlockingCT.get());
+        }
 
         if (!keepBlockingEDT.compareAndSet(false, true)) {
             log.fine("The secondary loop is already running, aborting");
             return false;
         }

@@ -188,13 +190,17 @@
         // dispatch thread, start a new event pump; if we're
         // on any other thread, call wait() on the treelock
 
         Thread currentThread = Thread.currentThread();
         if (currentThread == dispatchThread) {
+            if (log.isLoggable(PlatformLogger.FINEST)) {
             log.finest("On dispatch thread: " + dispatchThread);
+            }
             if (interval != 0) {
+                if (log.isLoggable(PlatformLogger.FINEST)) {
                 log.finest("scheduling the timer for " + interval + " ms");
+                }
                 timer.schedule(timerTask = new TimerTask() {
                     @Override
                     public void run() {
                         if (keepBlockingEDT.compareAndSet(true, false)) {
                             wakeupEDT();

@@ -205,11 +211,13 @@
             // Dispose SequencedEvent we are dispatching on the the current
             // AppContext, to prevent us from hang - see 4531693 for details
             SequencedEvent currentSE = KeyboardFocusManager.
                 getCurrentKeyboardFocusManager().getCurrentSequencedEvent();
             if (currentSE != null) {
+                if (log.isLoggable(PlatformLogger.FINE)) {
                 log.fine("Dispose current SequencedEvent: " + currentSE);
+                }
                 currentSE.dispose();
             }
             // In case the exit() method is called before starting
             // new event pump it will post the waking event to EDT.
             // The event will be handled after the the new event pump

@@ -221,11 +229,13 @@
                     run.run();
                     return null;
                 }
             });
         } else {
+            if (log.isLoggable(PlatformLogger.FINEST)) {
             log.finest("On non-dispatch thread: " + currentThread);
+            }
             synchronized (getTreeLock()) {
                 if (filter != null) {
                     dispatchThread.addEventFilter(filter);
                 }
                 try {

@@ -245,13 +255,17 @@
                                ((extCondition != null) ? extCondition.evaluate() : true))
                         {
                             getTreeLock().wait();
                         }
                     }
+                    if (log.isLoggable(PlatformLogger.FINE)) {
                     log.fine("waitDone " + keepBlockingEDT.get() + " " + keepBlockingCT.get());
+                    }
                 } catch (InterruptedException e) {
+                    if (log.isLoggable(PlatformLogger.FINE)) {
                     log.fine("Exception caught while waiting: " + e);
+                    }
                 } finally {
                     if (filter != null) {
                         dispatchThread.removeEventFilter(filter);
                     }
                 }

@@ -268,12 +282,14 @@
 
     /**
      * @inheritDoc
      */
     public boolean exit() {
+        if (log.isLoggable(PlatformLogger.FINE)) {
         log.fine("exit(): blockingEDT=" + keepBlockingEDT.get() +
                  ", blockingCT=" + keepBlockingCT.get());
+        }
         if (keepBlockingEDT.compareAndSet(true, false)) {
             wakeupEDT();
             return true;
         }
         return false;

@@ -293,10 +309,12 @@
             log.fine("Wake up EDT done");
         }
     };
 
     private void wakeupEDT() {
+        if (log.isLoggable(PlatformLogger.FINEST)) {
         log.finest("wakeupEDT(): EDT == " + dispatchThread);
+        }
         EventQueue eq = dispatchThread.getEventQueue();
         eq.postEvent(new PeerEvent(this, wakingRunnable, PeerEvent.PRIORITY_EVENT));
     }
 }