changeset 12335:e06161762a72

8080504: [macosx] SunToolkit.realSync() may hang Reviewed-by: serb, prr
author anashaty
date Mon, 29 Jun 2015 13:47:28 +0300
parents 58884c8b4ecf
children 2f3170c192c3
files src/java.desktop/macosx/native/libawt_lwawt/awt/LWCToolkit.m src/java.desktop/macosx/native/libosxapp/NSApplicationAWT.h src/java.desktop/macosx/native/libosxapp/NSApplicationAWT.m
diffstat 3 files changed, 10 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.desktop/macosx/native/libawt_lwawt/awt/LWCToolkit.m	Mon Jun 29 01:27:08 2015 +0300
+++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/LWCToolkit.m	Mon Jun 29 13:47:28 2015 +0300
@@ -376,7 +376,7 @@
     if ([sharedApp isKindOfClass:[NSApplicationAWT class]]) {
         NSApplicationAWT* theApp = (NSApplicationAWT*)sharedApp;
         [theApp postDummyEvent];
-        [theApp waitForDummyEvent];
+        [theApp waitForDummyEvent:timeout];
     } else {
         // could happen if we are embedded inside SWT application,
         // in this case just spin a single empty block through 
--- a/src/java.desktop/macosx/native/libosxapp/NSApplicationAWT.h	Mon Jun 29 01:27:08 2015 +0300
+++ b/src/java.desktop/macosx/native/libosxapp/NSApplicationAWT.h	Mon Jun 29 13:47:28 2015 +0300
@@ -38,7 +38,7 @@
 - (void) setDockIconWithEnv:(JNIEnv *)env;
 - (void) postDummyEvent;
 - (void) postRunnableEvent:(void (^)())block;
-- (void) waitForDummyEvent;
+- (void) waitForDummyEvent:(long long) timeout;
 
 + (void) runAWTLoopWithApp:(NSApplication*)app;
 
--- a/src/java.desktop/macosx/native/libosxapp/NSApplicationAWT.m	Mon Jun 29 01:27:08 2015 +0300
+++ b/src/java.desktop/macosx/native/libosxapp/NSApplicationAWT.m	Mon Jun 29 13:47:28 2015 +0300
@@ -398,8 +398,14 @@
     [pool drain];
 }
 
-- (void)waitForDummyEvent {
-    [seenDummyEventLock lockWhenCondition:YES];
+- (void)waitForDummyEvent:(long long) timeout {
+    if (timeout >= 0) {
+        double sec = ((double) timeout)/1000;
+        [seenDummyEventLock lockWhenCondition:YES
+                               beforeDate:[NSDate dateWithTimeIntervalSinceNow:sec]];
+    } else {
+        [seenDummyEventLock lockWhenCondition:YES];
+    }
     [seenDummyEventLock unlock];
     [seenDummyEventLock release];