From 3636cf2c640ab0b6a7c3b9d2358332bb52f4dc6e Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 5 Oct 2011 22:43:22 -0400 Subject: [PATCH 1/1] Update threads docs for the demise of g_thread_init() --- glib/gthread.c | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/glib/gthread.c b/glib/gthread.c index 9b328da..7ee385f 100644 --- a/glib/gthread.c +++ b/glib/gthread.c @@ -87,26 +87,23 @@ * facilities for one-time initialization (#GOnce, g_once_init_enter()). * Finally there are primitives to create and manage threads (#GThread). * - * The threading system is initialized with g_thread_init(). - * You may call any other GLib functions in the main thread before - * g_thread_init() as long as g_thread_init() is not called from - * a GLib callback, or with any locks held. However, many libraries - * above GLib do not support late initialization of threads, so - * doing this should be avoided if possible. - * - * Please note that since version 2.24 the GObject initialization - * function g_type_init() initializes threads. Since 2.32, creating - * a mainloop will do so too. As a consequence, most applications, - * including those using GTK+, will run with threads enabled. - * - * After calling g_thread_init(), GLib is completely thread safe - * (all global data is automatically locked), but individual data - * structure instances are not automatically locked for performance - * reasons. So, for example you must coordinate accesses to the same - * #GHashTable from multiple threads. The two notable exceptions from - * this rule are #GMainLoop and #GAsyncQueue, which are - * threadsafe and need no further application-level locking to be - * accessed from multiple threads. + * The GLib threading system used to be initialized with g_thread_init(). + * This is no longer necessary. Since version 2.32, the GLib threading + * system is automatically initialized at the start of your program, + * and all thread-creation functions and synchronization primitives + * are available right away. It is still possible to do thread-unsafe + * initialization and setup at the beginning of your program, before + * creating the first threads. + * + * GLib is internally completely thread-safe (all global data is + * automatically locked), but individual data structure instances are + * not automatically locked for performance reasons. For example, + * you must coordinate accesses to the same #GHashTable from multiple + * threads. The two notable exceptions from this rule are #GMainLoop + * and #GAsyncQueue, which are thread-safe and + * need no further application-level locking to be accessed from + * multiple threads. Most refcounting functions such as g_object_ref() + * are also thread-safe. */ /** -- 2.7.4