[3079] in BarnOwl Developers

home help back first fref pref prev next nref lref last post

[PATCH 1/2] make owl_select_post_task take a context argument to indicate /which/ running mainloop it should run the task on

daemon@ATHENA.MIT.EDU (Adam Glasgall)
Thu May 26 00:27:46 2011

From: Adam Glasgall <glasgall@MIT.EDU>
To: barnowl-dev@mit.edu
Cc: Adam Glasgall <adam@crossproduct.net>
Date: Thu, 26 May 2011 00:27:36 -0400
In-Reply-To: <1306384057-28479-1-git-send-email-glasgall@mit.edu>

From: Adam Glasgall <adam@crossproduct.net>

---
 owl.c    |    2 +-
 select.c |   14 +++++++++-----
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/owl.c b/owl.c
index 302283e..1450b3c 100644
--- a/owl.c
+++ b/owl.c
@@ -382,7 +382,7 @@ static void sig_handler(const siginfo_t *siginfo, void *data) {
   }
   /* Send a message to the main thread. */
   owl_select_post_task(sig_handler_main_thread,
-                       GINT_TO_POINTER(siginfo->si_signo), NULL);
+                       GINT_TO_POINTER(siginfo->si_signo), NULL, NULL);
 }
 
 #define CHECK_RESULT(s, syscall) \
diff --git a/select.c b/select.c
index 8dc6cd4..1c7b93f 100644
--- a/select.c
+++ b/select.c
@@ -1,7 +1,7 @@
 #include "owl.h"
 
 static GMainLoop *loop = NULL;
-static GMainContext *context;
+static GMainContext *main_context;
 static int dispatch_active = 0;
 
 static GSource *owl_timer_source;
@@ -343,8 +343,8 @@ void owl_select_init(void)
 
 void owl_select_run_loop(void)
 {
-  context = g_main_context_default();
-  loop = g_main_loop_new(context, FALSE);
+  main_context = g_main_context_default();
+  loop = g_main_loop_new(main_context, FALSE);
   g_main_loop_run(loop);
 }
 
@@ -378,7 +378,7 @@ static void _destroy_task(void *data)
   g_free(t);
 }
 
-void owl_select_post_task(void (*cb)(void*), void *cbdata, void (*destroy_cbdata)(void*))
+void owl_select_post_task(void (*cb)(void*), void *cbdata, void (*destroy_cbdata)(void*), GMainContext *context)
 {
   GSource *source = g_idle_source_new();
   owl_task *t = g_new0(owl_task, 1);
@@ -387,6 +387,10 @@ void owl_select_post_task(void (*cb)(void*), void *cbdata, void (*destroy_cbdata
   t->destroy_cbdata = destroy_cbdata;
   g_source_set_priority(source, G_PRIORITY_DEFAULT);
   g_source_set_callback(source, _run_task, t, _destroy_task);
-  g_source_attach(source, context);
+  if(context) {
+    g_source_attach(source, context);
+  } else {
+    g_source_attach(source, main_context);
+  }
   g_source_unref(source);
 }
-- 
1.7.2.3


home help back first fref pref prev next nref lref last post