< prev index next >

src/java.desktop/macosx/native/libosxapp/ThreadUtilities.h

Print this page
rev 54098 : 8260616: Removing remaining JNF dependencies in the java.desktop module
8259729: Missed JNFInstanceOf -> IsInstanceOf conversion


   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 #ifndef __THREADUTILITIES_H
  27 #define __THREADUTILITIES_H
  28 


  29 #import <pthread.h>
  30 
  31 #import "AWT_debug.h"
  32 
  33 
  34 // --------------------------------------------------------------------------
  35 #ifndef PRODUCT_BUILD
  36 
  37 // Turn on the AWT thread assert mechanism. See below for different variants.
  38 // TODO: don't enable this for production builds...
  39 #define AWT_THREAD_ASSERTS
  40 
  41 #endif /* PRODUCT_BUILD */
  42 // --------------------------------------------------------------------------
  43 
  44 // --------------------------------------------------------------------------
  45 #ifdef AWT_THREAD_ASSERTS
  46 
  47 // Turn on to have awt thread asserts display a message on the console.
  48 #define AWT_THREAD_ASSERTS_MESSAGES


 106 do {                                  \
 107     while (pthread_main_np() == 0) {} \
 108 } while (0)
 109 
 110 #define AWT_ASSERT_NOT_APPKIT_THREAD  \
 111 do {                                  \
 112     while (pthread_main_np() != 0) {} \
 113 } while (0)
 114 
 115 #endif /* AWT_THREAD_ASSERTS_WAIT */
 116 
 117 #else /* AWT_THREAD_ASSERTS */
 118 
 119 #define AWT_ASSERT_APPKIT_THREAD     do {} while (0)
 120 #define AWT_ASSERT_NOT_APPKIT_THREAD do {} while (0)
 121 
 122 #endif /* AWT_THREAD_ASSERTS */
 123 // --------------------------------------------------------------------------
 124 
 125 __attribute__((visibility("default")))
 126 @interface ThreadUtilities { }
 127 
 128 + (JNIEnv*)getJNIEnv;
 129 + (JNIEnv*)getJNIEnvUncached;
 130 + (void)detachCurrentThread;
 131 + (void)setAppkitThreadGroup:(jobject)group;
 132 
 133 //Wrappers for the corresponding JNFRunLoop methods with a check for main thread
 134 + (void)performOnMainThreadWaiting:(BOOL)wait block:(void (^)())block;
 135 + (void)performOnMainThread:(SEL)aSelector on:(id)target withObject:(id)arg waitUntilDone:(BOOL)wait;

 136 @end
 137 
 138 void OSXAPP_SetJavaVM(JavaVM *vm);
 139 
 140 #endif /* __THREADUTILITIES_H */


   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 #ifndef __THREADUTILITIES_H
  27 #define __THREADUTILITIES_H
  28 
  29 #include "jni.h"
  30 
  31 #import <pthread.h>
  32 
  33 #import "AWT_debug.h"
  34 
  35 
  36 // --------------------------------------------------------------------------
  37 #ifndef PRODUCT_BUILD
  38 
  39 // Turn on the AWT thread assert mechanism. See below for different variants.
  40 // TODO: don't enable this for production builds...
  41 #define AWT_THREAD_ASSERTS
  42 
  43 #endif /* PRODUCT_BUILD */
  44 // --------------------------------------------------------------------------
  45 
  46 // --------------------------------------------------------------------------
  47 #ifdef AWT_THREAD_ASSERTS
  48 
  49 // Turn on to have awt thread asserts display a message on the console.
  50 #define AWT_THREAD_ASSERTS_MESSAGES


 108 do {                                  \
 109     while (pthread_main_np() == 0) {} \
 110 } while (0)
 111 
 112 #define AWT_ASSERT_NOT_APPKIT_THREAD  \
 113 do {                                  \
 114     while (pthread_main_np() != 0) {} \
 115 } while (0)
 116 
 117 #endif /* AWT_THREAD_ASSERTS_WAIT */
 118 
 119 #else /* AWT_THREAD_ASSERTS */
 120 
 121 #define AWT_ASSERT_APPKIT_THREAD     do {} while (0)
 122 #define AWT_ASSERT_NOT_APPKIT_THREAD do {} while (0)
 123 
 124 #endif /* AWT_THREAD_ASSERTS */
 125 // --------------------------------------------------------------------------
 126 
 127 __attribute__((visibility("default")))
 128 @interface ThreadUtilities : NSObject { } /* Extend NSObject so can call performSelectorOnMainThread */
 129 
 130 + (JNIEnv*)getJNIEnv;
 131 + (JNIEnv*)getJNIEnvUncached;
 132 + (void)detachCurrentThread;
 133 + (void)setAppkitThreadGroup:(jobject)group;
 134 

 135 + (void)performOnMainThreadWaiting:(BOOL)wait block:(void (^)())block;
 136 + (void)performOnMainThread:(SEL)aSelector on:(id)target withObject:(id)arg waitUntilDone:(BOOL)wait;
 137 + (NSString*)javaRunLoopMode;
 138 @end
 139 
 140 void OSXAPP_SetJavaVM(JavaVM *vm);
 141 
 142 #endif /* __THREADUTILITIES_H */
< prev index next >