[patch] Multiple/Java thread support
- From: Paul Fisher <rao gnu org>
- To: gtk-list redhat com
- Subject: [patch] Multiple/Java thread support
- Date: 10 Sep 1998 13:33:14 +-400
I've uploaded gtk-rao-980910-0.patch.gz to incoming. The patch is
against the CVS tree as of approximately 11:00AM EDT. If anyone would
like a patch for gtk+-1.1.1, please send me an email.
README:
Multiple Thread Library Support + Java Thread Support
GTK's current threading primitives are hardcoded for pthreads. The
GNU Classpath Project (http://www.classpath.org) is writing a Java AWT
implementation using GTK+. As such, we needed to make gdkthreads work
with the threading facilities provided by the Java Virtual Machine.
As opposed to adding the ability to compile GTK for either pthreads or
JNI (java) threads, I went ahead and extended GTK's threading
primitives to easily switch between different thread implementations
based on the application using libgtk. It should now be trivial to
add new thread library support -- such as cthreads or Sun threads.
The new threading calls are structured as follows:
gboolean gdk_threads_init (GdkThreadsType threads_type, ...);
void gdk_threads_enter (GdkThreadsType threads_type, ...);
void gdk_threads_leave (GdkThreadsType threads_type, ...);
GdkThreadsType is defined as:
typedef enum
{
GDK_THREADS_INTERNAL, /* calls from within the GDK thread */
GDK_THREADS_PTHREADS, /* posix threads */
GDK_THREADS_JNI /* java threads */
} GdkThreadsType;
A GTK application requests what type of threading it would like for
GDK to use, by passing a GdkThreadsType to gdk_threads_init. Varargs
are used accordingly if the GdkThreadsType needs any initialization
parameters. The same calling convention is used for
gdk_threads_{enter/leave}.
Whenever GDK internally calls gdk_threads_{enter/leave},
GDK_THREADS_INTERNAL is passed without any extra parameters, as any
needed thread info was passed in with the original init. Thus, under
certain threading libraries, there may be a requirement that the
thread calling gdk_threads_init is also the thread which runs the
event loop.
Java threads require the varargs to pass in a Java interface pointer
which is associated with the calling thread. Pthreads do not have
this type of requirement.
So all the old pthreads code of the form:
gdk_threads_init ();
...
gdk_threads_enter ();
[gtk calls]
gdk_threads_leave ();
now becomes:
gdk_threads_init (GDK_THREADS_PTHREADS);
...
gdk_threads_enter (GDK_THREADS_PTHREADS);
[gtk calls]
gdk_threads_leave (GDK_THREADS_PTHREADS);
Java threads are called in the following manner, where "env" is the
Java interface pointer (type: JNIEnv *).
gdk_threads_init (GDK_THREADS_JNI, env);
...
gdk_threads_enter (GDK_THREADS_JNI, env);
[gtk calls]
gdk_threads_leave (GDK_THREADS_JNI, env);
For any thread calls within GDK, regardless of the threading type the
application has requested, the following form is used:
gdk_threads_enter (GDK_THREADS_INTERNAL);
...
gdk_threads_leave (GDK_THREADS_INTERNAL);
configure.in has been modified as well. --with-threads has been
removed, and --with-posix-threads and --with-java-threads have been
added. If --with-posix-threads is successful, USE_PTHREADS is
defined. If --with-java-threads is successful, USE_JNI_THREADS is
defined. If either is successful, USE_THREADS is defined, and
-D_REENTRANT is added to the CFLAGS.
PATCH:
begin 664 gtk-rao-980910-0.patch.gz
M'XL("/@$^#4``V=T:RUR86\M.3@P.3$P+3`N<&%T8V@`U1K]5^)(\F?Y*VIP
M=C<80$%QU%GG#:/HL,.@#W%GWLW-RPO00#0FN7PHWJS_^U5U=T(G!&1N9_?=
M\90DU=55U?7551U&UG@,%1\J$;CV:'L2WNK;YG#H.F-K4IU"YKE0J53R\#;Z
MTPBNF`>U'?P[VCDXVGT%M</#@X*NZUDB6>3#H]VZ0'[[%BJ[^^5]T/$;1]^^
M+4`!MK?@E(TMAT'H`G/,@<W@\N*J_1G"J<_,D>5,P'PP?>:P(("M[0)L1LZ(
MC>'ZJF5<]M_W6LW3JX*>1^8W\]Y<1D57J/S6;1LYA*PQF,XCA(\>`W><2\@*
M)*]1EF9,#Q)Y/[>[E]=]HWO1;65AYY_;A5&.J81.(Y]5+0<6(&ESJ2-K&&P%
M>JU^U-B=FVS_5?D5Z/A]R"W6/#&:O7/C4[O_7K/=H6FS,GP!J%0>K'!:$9#C
MSL5)L],"_`@`..8=@T<W@@?3"<E$4<#@:XG4HQ*<68X7A2I!`3G^XKC;DYFU
M/1O[C'V%(/(\UP]1?S1*A"HJ&6&J0*4C0<=?/#>P9G,*<ZLB$5TEPA$K.:12
M`[3&F)8G85E*-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