[glib/wip/gcleanup: 13/21] gmain: Use a simpler method for cleanup of glib_worker thread
- From: Stefan Walter <stefw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/wip/gcleanup: 13/21] gmain: Use a simpler method for cleanup of glib_worker thread
- Date: Thu, 7 Nov 2013 07:21:44 +0000 (UTC)
commit 73560e011b725b85515853e44e74640fdec93fd3
Author: Stef Walter <stefw gnome org>
Date: Thu Oct 31 14:39:48 2013 +0100
gmain: Use a simpler method for cleanup of glib_worker thread
Using g_main_context_invoke() here hits way too much code that
has already been cleaned up at this point. Besides, this is simpler.
https://bugzilla.gnome.org/show_bug.cgi?id=627423
glib/gmain.c | 14 ++++----------
1 files changed, 4 insertions(+), 10 deletions(-)
---
diff --git a/glib/gmain.c b/glib/gmain.c
index 2205e49..e2296e7 100644
--- a/glib/gmain.c
+++ b/glib/gmain.c
@@ -413,7 +413,7 @@ static void block_source (GSource *source);
static GThread *glib_worker_thread;
static GMainContext *glib_worker_context;
-static gboolean glib_worker_quit_requested;
+static gint glib_worker_quit_requested;
G_LOCK_DEFINE_STATIC (main_loop);
static GMainContext *default_main_context;
@@ -5475,7 +5475,7 @@ g_main_context_invoke_full (GMainContext *context,
static gpointer
glib_worker_main (gpointer data)
{
- while (!glib_worker_quit_requested)
+ while (!g_atomic_int_get (&glib_worker_quit_requested))
{
g_main_context_iteration (glib_worker_context, TRUE);
@@ -5488,17 +5488,11 @@ glib_worker_main (gpointer data)
return NULL;
}
-static gboolean
-return_false (gpointer user_data)
-{
- return FALSE;
-}
-
static void
glib_worker_kill (void)
{
- glib_worker_quit_requested = TRUE;
- g_main_context_invoke (glib_worker_context, return_false, NULL);
+ g_atomic_int_set (&glib_worker_quit_requested, 1);
+ g_main_context_wakeup (glib_worker_context);
g_thread_join (glib_worker_thread);
glib_worker_thread = NULL;
g_main_context_unref (glib_worker_context);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]