mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-07 19:35:50 +01:00
Factor out g_main_context_init_pipe from g_main_context_new to initialize
2002-08-06 Sebastian Wilhelmi <wilhelmi@ira.uka.de> * 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)
This commit is contained in:
parent
3faf95913d
commit
659fd4113b
@ -9,6 +9,14 @@
|
||||
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()
|
||||
|
@ -9,6 +9,14 @@
|
||||
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()
|
||||
|
@ -9,6 +9,14 @@
|
||||
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()
|
||||
|
@ -9,6 +9,14 @@
|
||||
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()
|
||||
|
@ -9,6 +9,14 @@
|
||||
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()
|
||||
|
@ -9,6 +9,14 @@
|
||||
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()
|
||||
|
@ -9,6 +9,14 @@
|
||||
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()
|
||||
|
69
glib/gmain.c
69
glib/gmain.c
@ -219,6 +219,7 @@ static gboolean g_idle_dispatch (GSource *source,
|
||||
|
||||
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)
|
||||
@ -568,6 +569,9 @@ g_main_context_unref_and_unlock (GMainContext *context)
|
||||
CloseHandle (context->wake_up_semaphore);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
main_contexts_without_pipe = g_slist_remove (main_contexts_without_pipe,
|
||||
context);
|
||||
#endif
|
||||
|
||||
g_free (context);
|
||||
@ -590,6 +594,45 @@ g_main_context_unref (GMainContext *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:
|
||||
*
|
||||
@ -630,28 +673,10 @@ g_main_context_new ()
|
||||
|
||||
#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
|
||||
}
|
||||
g_main_context_init_pipe (context);
|
||||
else
|
||||
main_contexts_without_pipe = g_slist_prepend (main_contexts_without_pipe,
|
||||
context);
|
||||
#endif
|
||||
|
||||
return context;
|
||||
|
@ -66,6 +66,7 @@ void g_mutex_init (void);
|
||||
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)))
|
||||
|
||||
@ -381,6 +382,7 @@ g_thread_init (GThreadFunctions* init)
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user