56 } 57 return appKitEnv; 58 } 59 60 + (JNIEnv*)getJNIEnvUncached { 61 JNIEnv *env = NULL; 62 attachCurrentThread((void **)&env); 63 return env; 64 } 65 66 + (void)detachCurrentThread { 67 (*jvm)->DetachCurrentThread(jvm); 68 } 69 70 + (void)setAppkitThreadGroup:(jobject)group { 71 appkitThreadGroup = group; 72 } 73 74 + (void)performOnMainThreadWaiting:(BOOL)wait block:(void (^)())block { 75 if ([NSThread isMainThread] && wait == YES) { 76 block(); 77 } else { 78 [JNFRunLoop performOnMainThreadWaiting:wait withBlock:block]; 79 } 80 } 81 82 + (void)performOnMainThread:(SEL)aSelector on:(id)target withObject:(id)arg waitUntilDone:(BOOL)wait { 83 if ([NSThread isMainThread] && wait == YES) { 84 [target performSelector:aSelector withObject:arg]; 85 } else { 86 [JNFRunLoop performOnMainThread:aSelector on:target withObject:arg waitUntilDone:wait]; 87 } 88 } 89 90 @end 91 92 93 void OSXAPP_SetJavaVM(JavaVM *vm) 94 { 95 jvm = vm; 96 } 97 | 56 } 57 return appKitEnv; 58 } 59 60 + (JNIEnv*)getJNIEnvUncached { 61 JNIEnv *env = NULL; 62 attachCurrentThread((void **)&env); 63 return env; 64 } 65 66 + (void)detachCurrentThread { 67 (*jvm)->DetachCurrentThread(jvm); 68 } 69 70 + (void)setAppkitThreadGroup:(jobject)group { 71 appkitThreadGroup = group; 72 } 73 74 + (void)performOnMainThreadWaiting:(BOOL)wait block:(void (^)())block { 75 if ([NSThread isMainThread] && wait == YES) { 76 block(); 77 } else { 78 [JNFRunLoop performOnMainThreadWaiting:wait withBlock:block]; 79 } 80 } 81 82 + (void)performOnMainThread:(SEL)aSelector on:(id)target withObject:(id)arg waitUntilDone:(BOOL)wait { 83 if ([NSThread isMainThread] && wait == YES) { 84 [target performSelector:aSelector withObject:arg]; 85 } else { 86 [JNFRunLoop performOnMainThread:aSelector on:target withObject:arg waitUntilDone:wait]; 87 } 88 } 89 90 @end 91 92 93 void OSXAPP_SetJavaVM(JavaVM *vm) 94 { 95 jvm = vm; 96 } 97 |