228 sAWTThreadAsserts = (getenv("COCOA_AWT_DISABLE_THREAD_ASSERTS") == NULL); 229 #endif /* AWT_THREAD_ASSERTS_ENV_ASSERT */ 230 } 231 } 232 233 // These methods can behave slightly differently than the normal 234 // performSelector... In particular, we define a special runloop mode 235 // (AWTRunLoopMode) so that we can "block" the main thread against the 236 // java event thread without deadlocking. See CToolkit.invokeAndWait. 237 + (void)performOnMainThread:(SEL)aSelector onObject:(id)target withObject:(id)arg waitUntilDone:(BOOL)wait awtMode:(BOOL)inAWT { 238 CPerformer *performer = [[CPerformer alloc] initWithTarget:target selector:aSelector arg:arg wait:wait]; 239 if (sCocoaComponentCompatibility && wait && inAWT) { 240 [performer performCompatible]; 241 [performer autorelease]; 242 } else { 243 [performer performSelectorOnMainThread:@selector(perform) withObject:nil waitUntilDone:wait modes:((inAWT) ? sAWTPerformModes : sPerformModes)]; // AWT_THREADING Safe (cover method) 244 [performer release]; 245 } 246 } 247 248 @end 249 250 251 void OSXAPP_SetJavaVM(JavaVM *vm) 252 { 253 jvm = vm; 254 } 255 | 228 sAWTThreadAsserts = (getenv("COCOA_AWT_DISABLE_THREAD_ASSERTS") == NULL); 229 #endif /* AWT_THREAD_ASSERTS_ENV_ASSERT */ 230 } 231 } 232 233 // These methods can behave slightly differently than the normal 234 // performSelector... In particular, we define a special runloop mode 235 // (AWTRunLoopMode) so that we can "block" the main thread against the 236 // java event thread without deadlocking. See CToolkit.invokeAndWait. 237 + (void)performOnMainThread:(SEL)aSelector onObject:(id)target withObject:(id)arg waitUntilDone:(BOOL)wait awtMode:(BOOL)inAWT { 238 CPerformer *performer = [[CPerformer alloc] initWithTarget:target selector:aSelector arg:arg wait:wait]; 239 if (sCocoaComponentCompatibility && wait && inAWT) { 240 [performer performCompatible]; 241 [performer autorelease]; 242 } else { 243 [performer performSelectorOnMainThread:@selector(perform) withObject:nil waitUntilDone:wait modes:((inAWT) ? sAWTPerformModes : sPerformModes)]; // AWT_THREADING Safe (cover method) 244 [performer release]; 245 } 246 } 247 248 + (void)performOnMainThreadWaiting:(BOOL)wait block:(void (^)())block { 249 if ([NSThread isMainThread] && wait == YES) { 250 block(); 251 } else { 252 [JNFRunLoop performOnMainThreadWaiting:wait withBlock:block]; 253 } 254 } 255 256 @end 257 258 259 void OSXAPP_SetJavaVM(JavaVM *vm) 260 { 261 jvm = vm; 262 } 263 |