thread, because all unbound threads will schedule according to
that value and it defaults to 0 (the minimal value).
+ * glib/gmain.c: Factor out g_main_context_init_pipe from
+ g_main_context_new to initialize the wakeup pipe of a
+ context. Call that function from g_main_context_new if threads are
+ initialized and for all contexts when threads are initialized
+ in g_main_thread_init. (#86872)
+
+ * gthread/gthread-impl.c: Call g_main_thread_init. (#86872)
+
Thu Jul 25 14:23:15 2002 Owen Taylor <otaylor@redhat.com>
* glib/gfileutils.c: Clarify the behavior of g_build_path()
thread, because all unbound threads will schedule according to
that value and it defaults to 0 (the minimal value).
+ * glib/gmain.c: Factor out g_main_context_init_pipe from
+ g_main_context_new to initialize the wakeup pipe of a
+ context. Call that function from g_main_context_new if threads are
+ initialized and for all contexts when threads are initialized
+ in g_main_thread_init. (#86872)
+
+ * gthread/gthread-impl.c: Call g_main_thread_init. (#86872)
+
Thu Jul 25 14:23:15 2002 Owen Taylor <otaylor@redhat.com>
* glib/gfileutils.c: Clarify the behavior of g_build_path()
thread, because all unbound threads will schedule according to
that value and it defaults to 0 (the minimal value).
+ * glib/gmain.c: Factor out g_main_context_init_pipe from
+ g_main_context_new to initialize the wakeup pipe of a
+ context. Call that function from g_main_context_new if threads are
+ initialized and for all contexts when threads are initialized
+ in g_main_thread_init. (#86872)
+
+ * gthread/gthread-impl.c: Call g_main_thread_init. (#86872)
+
Thu Jul 25 14:23:15 2002 Owen Taylor <otaylor@redhat.com>
* glib/gfileutils.c: Clarify the behavior of g_build_path()
thread, because all unbound threads will schedule according to
that value and it defaults to 0 (the minimal value).
+ * glib/gmain.c: Factor out g_main_context_init_pipe from
+ g_main_context_new to initialize the wakeup pipe of a
+ context. Call that function from g_main_context_new if threads are
+ initialized and for all contexts when threads are initialized
+ in g_main_thread_init. (#86872)
+
+ * gthread/gthread-impl.c: Call g_main_thread_init. (#86872)
+
Thu Jul 25 14:23:15 2002 Owen Taylor <otaylor@redhat.com>
* glib/gfileutils.c: Clarify the behavior of g_build_path()
thread, because all unbound threads will schedule according to
that value and it defaults to 0 (the minimal value).
+ * glib/gmain.c: Factor out g_main_context_init_pipe from
+ g_main_context_new to initialize the wakeup pipe of a
+ context. Call that function from g_main_context_new if threads are
+ initialized and for all contexts when threads are initialized
+ in g_main_thread_init. (#86872)
+
+ * gthread/gthread-impl.c: Call g_main_thread_init. (#86872)
+
Thu Jul 25 14:23:15 2002 Owen Taylor <otaylor@redhat.com>
* glib/gfileutils.c: Clarify the behavior of g_build_path()
thread, because all unbound threads will schedule according to
that value and it defaults to 0 (the minimal value).
+ * glib/gmain.c: Factor out g_main_context_init_pipe from
+ g_main_context_new to initialize the wakeup pipe of a
+ context. Call that function from g_main_context_new if threads are
+ initialized and for all contexts when threads are initialized
+ in g_main_thread_init. (#86872)
+
+ * gthread/gthread-impl.c: Call g_main_thread_init. (#86872)
+
Thu Jul 25 14:23:15 2002 Owen Taylor <otaylor@redhat.com>
* glib/gfileutils.c: Clarify the behavior of g_build_path()
thread, because all unbound threads will schedule according to
that value and it defaults to 0 (the minimal value).
+ * glib/gmain.c: Factor out g_main_context_init_pipe from
+ g_main_context_new to initialize the wakeup pipe of a
+ context. Call that function from g_main_context_new if threads are
+ initialized and for all contexts when threads are initialized
+ in g_main_thread_init. (#86872)
+
+ * gthread/gthread-impl.c: Call g_main_thread_init. (#86872)
+
Thu Jul 25 14:23:15 2002 Owen Taylor <otaylor@redhat.com>
* glib/gfileutils.c: Clarify the behavior of g_build_path()
G_LOCK_DEFINE_STATIC (main_loop);
static GMainContext *default_main_context;
+static GSList *main_contexts_without_pipe = NULL;
#if defined(G_PLATFORM_WIN32) && defined(__GNUC__)
__declspec(dllexport)
#else
CloseHandle (context->wake_up_semaphore);
#endif
- }
+ }
+ else
+ main_contexts_without_pipe = g_slist_remove (main_contexts_without_pipe,
+ context);
#endif
g_free (context);
g_main_context_unref_and_unlock (context);
}
+#ifdef G_THREADS_ENABLED
+static void
+g_main_context_init_pipe (GMainContext *context)
+{
+# ifndef G_OS_WIN32
+ if (pipe (context->wake_up_pipe) < 0)
+ g_error ("Cannot create pipe main loop wake-up: %s\n",
+ g_strerror (errno));
+
+ context->wake_up_rec.fd = context->wake_up_pipe[0];
+ context->wake_up_rec.events = G_IO_IN;
+# else
+ context->wake_up_semaphore = CreateSemaphore (NULL, 0, 100, NULL);
+ if (context->wake_up_semaphore == NULL)
+ g_error ("Cannot create wake-up semaphore: %s",
+ g_win32_error_message (GetLastError ()));
+ context->wake_up_rec.fd = (gint) context->wake_up_semaphore;
+ context->wake_up_rec.events = G_IO_IN;
+# ifdef G_MAIN_POLL_DEBUG
+ g_print ("wake-up semaphore: %#x\n", (guint) context->wake_up_semaphore);
+# endif
+# endif
+ g_main_context_add_poll_unlocked (context, 0, &context->wake_up_rec);
+}
+
+void
+g_main_thread_init ()
+{
+ GSList *curr = main_contexts_without_pipe;
+ while (curr)
+ {
+ g_main_context_init_pipe ((GMainContext *)curr->data);
+ curr = curr->next;
+ }
+ g_slist_free (main_contexts_without_pipe);
+ main_contexts_without_pipe = NULL;
+}
+#endif /* G_THREADS_ENABLED */
+
/**
* g_main_context_new:
*
context->ref_count = 1;
- context->next_id = 1;
-
- context->source_list = NULL;
-
+ context->next_id = 1;
+
+ context->source_list = NULL;
+
#if HAVE_POLL
- context->poll_func = (GPollFunc)poll;
+ context->poll_func = (GPollFunc)poll;
#else
- context->poll_func = g_poll;
+ context->poll_func = g_poll;
#endif
-
- context->cached_poll_array = NULL;
- context->cached_poll_array_size = 0;
-
- context->pending_dispatches = g_ptr_array_new ();
-
- context->time_is_current = FALSE;
-
+
+ context->cached_poll_array = NULL;
+ context->cached_poll_array_size = 0;
+
+ context->pending_dispatches = g_ptr_array_new ();
+
+ context->time_is_current = FALSE;
+
#ifdef G_THREADS_ENABLED
- if (g_thread_supported ())
- {
-#ifndef G_OS_WIN32
- if (pipe (context->wake_up_pipe) < 0)
- g_error ("Cannot create pipe main loop wake-up: %s\n",
- g_strerror (errno));
-
- context->wake_up_rec.fd = context->wake_up_pipe[0];
- context->wake_up_rec.events = G_IO_IN;
- g_main_context_add_poll_unlocked (context, 0, &context->wake_up_rec);
-#else
- context->wake_up_semaphore = CreateSemaphore (NULL, 0, 100, NULL);
- if (context->wake_up_semaphore == NULL)
- g_error ("Cannot create wake-up semaphore: %s",
- g_win32_error_message (GetLastError ()));
- context->wake_up_rec.fd = (gint) context->wake_up_semaphore;
- context->wake_up_rec.events = G_IO_IN;
-#ifdef G_MAIN_POLL_DEBUG
- g_print ("wake-up semaphore: %#x\n", (guint) context->wake_up_semaphore);
-#endif
- g_main_context_add_poll_unlocked (context, 0, &context->wake_up_rec);
-#endif
- }
+ if (g_thread_supported ())
+ g_main_context_init_pipe (context);
+ else
+ main_contexts_without_pipe = g_slist_prepend (main_contexts_without_pipe,
+ context);
#endif
return context;
void g_mem_init (void);
void g_messages_init (void);
void g_convert_init (void);
+void g_main_thread_init (void);
#define G_MUTEX_DEBUG_INFO(mutex) (*((gpointer*)(((char*)mutex)+G_MUTEX_SIZE)))
g_mem_init ();
g_messages_init ();
g_convert_init ();
+ g_main_thread_init ();
/* now we can set g_threads_got_initialized and thus enable
* all the thread functions