[libbluray-devel] stopEventQueue(): wait until all events have been processed

hpi1 git at videolan.org
Tue Apr 9 22:15:18 CEST 2013


libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Tue Apr  9 09:50:52 2013 +0300| [16ba6dfcba1c20df2487aee419b19d556f5086af] | committer: hpi1

stopEventQueue(): wait until all events have been processed

> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=16ba6dfcba1c20df2487aee419b19d556f5086af
---

 src/libbluray/bdj/java/java/awt/BDRootWindow.java |   18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/src/libbluray/bdj/java/java/awt/BDRootWindow.java b/src/libbluray/bdj/java/java/awt/BDRootWindow.java
index 58dc5ad..c5b5c13 100644
--- a/src/libbluray/bdj/java/java/awt/BDRootWindow.java
+++ b/src/libbluray/bdj/java/java/awt/BDRootWindow.java
@@ -19,6 +19,7 @@
 
 package java.awt;
 
+import java.awt.event.InvocationEvent;
 import java.awt.event.KeyEvent;
 import java.util.Arrays;
 import java.util.Timer;
@@ -69,6 +70,23 @@ public class BDRootWindow extends Frame {
     public static void stopEventQueue(EventQueue eq) {
         EventDispatchThread t = eq.getDispatchThread();
         if (t != null) {
+
+            final long DISPOSAL_TIMEOUT = 5000;
+            final Object notificationLock = new Object();
+            Runnable runnable = new Runnable() { public void run() {
+                synchronized(notificationLock) {
+                    notificationLock.notifyAll();
+                }
+            } };
+
+            synchronized (notificationLock) {
+                eq.postEvent(new InvocationEvent(Toolkit.getDefaultToolkit(), runnable));
+                try {
+                    notificationLock.wait(DISPOSAL_TIMEOUT);
+                } catch (InterruptedException e) {
+                }
+            }
+
             t.stopDispatching();
         }
     }



More information about the libbluray-devel mailing list