changeset 12407:59f199bb566b

8080504: [macosx] SunToolkit.realSync() may hang Reviewed-by: serb, prr
author anashaty
date Sat, 26 Aug 2017 14:53:36 +0100
parents 6190d1db8b92
children 11f7deebf7ae
files src/macosx/native/sun/awt/LWCToolkit.m src/macosx/native/sun/osxapp/NSApplicationAWT.h src/macosx/native/sun/osxapp/NSApplicationAWT.m
diffstat 3 files changed, 10 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/macosx/native/sun/awt/LWCToolkit.m	Fri Aug 25 11:52:49 2017 -0400
+++ b/src/macosx/native/sun/awt/LWCToolkit.m	Sat Aug 26 14:53:36 2017 +0100
@@ -137,7 +137,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/macosx/native/sun/osxapp/NSApplicationAWT.h	Fri Aug 25 11:52:49 2017 -0400
+++ b/src/macosx/native/sun/osxapp/NSApplicationAWT.h	Sat Aug 26 14:53:36 2017 +0100
@@ -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/macosx/native/sun/osxapp/NSApplicationAWT.m	Fri Aug 25 11:52:49 2017 -0400
+++ b/src/macosx/native/sun/osxapp/NSApplicationAWT.m	Sat Aug 26 14:53:36 2017 +0100
@@ -397,8 +397,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];