Update threads docs for the demise of g_thread_init()

This commit is contained in:
Matthias Clasen 2011-10-05 22:43:22 -04:00
parent 47c7fa2ccd
commit 3636cf2c64

View File

@ -87,26 +87,23 @@
* facilities for one-time initialization (#GOnce, g_once_init_enter()). * facilities for one-time initialization (#GOnce, g_once_init_enter()).
* Finally there are primitives to create and manage threads (#GThread). * Finally there are primitives to create and manage threads (#GThread).
* *
* The threading system is initialized with g_thread_init(). * The GLib threading system used to be initialized with g_thread_init().
* You may call any other GLib functions in the main thread before * This is no longer necessary. Since version 2.32, the GLib threading
* g_thread_init() as long as g_thread_init() is not called from * system is automatically initialized at the start of your program,
* a GLib callback, or with any locks held. However, many libraries * and all thread-creation functions and synchronization primitives
* above GLib do not support late initialization of threads, so * are available right away. It is still possible to do thread-unsafe
* doing this should be avoided if possible. * initialization and setup at the beginning of your program, before
* creating the first threads.
* *
* Please note that since version 2.24 the GObject initialization * GLib is internally completely thread-safe (all global data is
* function g_type_init() initializes threads. Since 2.32, creating * automatically locked), but individual data structure instances are
* a mainloop will do so too. As a consequence, most applications, * not automatically locked for performance reasons. For example,
* including those using GTK+, will run with threads enabled. * you must coordinate accesses to the same #GHashTable from multiple
* * threads. The two notable exceptions from this rule are #GMainLoop
* After calling g_thread_init(), GLib is completely thread safe * and #GAsyncQueue, which <emphasis>are</emphasis> thread-safe and
* (all global data is automatically locked), but individual data * need no further application-level locking to be accessed from
* structure instances are not automatically locked for performance * multiple threads. Most refcounting functions such as g_object_ref()
* reasons. So, for example you must coordinate accesses to the same * are also thread-safe.
* #GHashTable from multiple threads. The two notable exceptions from
* this rule are #GMainLoop and #GAsyncQueue, which <emphasis>are</emphasis>
* threadsafe and need no further application-level locking to be
* accessed from multiple threads.
*/ */
/** /**