gtk2/docs/reference/gdk/tmpl/threads.sgml

85 lines
1.9 KiB
Plaintext
Raw Normal View History

1999-08-16 18:51:52 +00:00
<!-- ##### SECTION Title ##### -->
Threads
<!-- ##### SECTION Short_Description ##### -->
functions for using GDK in multi-threaded programs
1999-08-16 18:51:52 +00:00
<!-- ##### SECTION Long_Description ##### -->
<para>
For thread safety, GDK relies on the thread primitives in GLib,
and on the thread-safe GLib main loop.
</para>
<para>
You must call g_thread_init() before executing any other GTK+ or GDK
functions in a threaded GTK+ program.
</para>
<para>
Idles, timeouts, and input functions are executed outside
of the main GTK+ lock. So, if you need to call GTK+
inside of such a callback, you must surround the callback
with a gdk_threads_enter()/gdk_threads_leave() pair.
(However, signals are still executed within the main
GTK+ lock.)
</para>
<para>
In particular, this means, if you are writing widgets that might
be used in threaded programs, you <emphasis>must</emphasis> surround
timeouts and idle functions in this matter.
</para>
<para>
As always, you must also surround any calls to GTK+ not made within
a signal handler with a gdk_threads_enter()/gdk_threads_leave() pair.
1999-08-16 18:51:52 +00:00
</para>
<!-- ##### SECTION See_Also ##### -->
<para>
</para>
<!-- ##### MACRO GDK_THREADS_ENTER ##### -->
<para>
This macro marks the begin of a critical section
in which GDK and GTK+ functions can be called.
Only one thread at a time can be in such a critial
section.
1999-08-16 18:51:52 +00:00
</para>
<!-- ##### MACRO GDK_THREADS_LEAVE ##### -->
<para>
This macro marks the end of a critical section
begun with #GDK_THREADS_ENTER.
1999-08-16 18:51:52 +00:00
</para>
<!-- ##### FUNCTION gdk_threads_init ##### -->
<para>
</para>
1999-08-16 18:51:52 +00:00
<!-- ##### FUNCTION gdk_threads_enter ##### -->
<para>
Enters a critical region like #GDK_THREADS_ENTER.
1999-08-16 18:51:52 +00:00
</para>
<!-- ##### FUNCTION gdk_threads_leave ##### -->
<para>
Leaves a critical region begun with gdk_threads_enter().
1999-08-16 18:51:52 +00:00
</para>
<!-- ##### VARIABLE gdk_threads_mutex ##### -->
<para>
The #GMutex used to implement the critical region for
gdk_threads_enter()/gdk_threads_leave().
</para>