[glib/wip/gsubprocess] GSubprocess: [rebase] Clean up add/create watch API
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/wip/gsubprocess] GSubprocess: [rebase] Clean up add/create watch API
- Date: Mon, 11 Jun 2012 21:07:38 +0000 (UTC)
commit 3dd52beb3e6005d9c4702423da63cae62e9427ea
Author: Colin Walters <walters verbum org>
Date: Mon Jun 11 17:07:01 2012 -0400
GSubprocess: [rebase] Clean up add/create watch API
docs/reference/gio/gio-sections.txt | 1 -
gio/gio.symbols | 1 -
gio/gsubprocess.c | 62 +++++++++++-----------------------
gio/gsubprocess.h | 15 +++------
gio/tests/gsubprocess.c | 18 ++++------
5 files changed, 33 insertions(+), 64 deletions(-)
---
diff --git a/docs/reference/gio/gio-sections.txt b/docs/reference/gio/gio-sections.txt
index 2740447..8ad557a 100644
--- a/docs/reference/gio/gio-sections.txt
+++ b/docs/reference/gio/gio-sections.txt
@@ -3931,7 +3931,6 @@ g_subprocess_set_working_directory
g_subprocess_start_with_pipes
g_subprocess_start
g_subprocess_add_watch
-g_subprocess_add_watch_full
g_subprocess_run_sync
g_subprocess_wait_sync
g_subprocess_request_exit
diff --git a/gio/gio.symbols b/gio/gio.symbols
index 45b9576..4b82d7f 100644
--- a/gio/gio.symbols
+++ b/gio/gio.symbols
@@ -1077,7 +1077,6 @@ g_tcp_connection_get_type
g_tcp_connection_set_graceful_disconnect
g_tcp_connection_get_graceful_disconnect
g_subprocess_add_watch
-g_subprocess_add_watch_full
g_subprocess_append_arg
g_subprocess_append_args
g_subprocess_append_args_va
diff --git a/gio/gsubprocess.c b/gio/gsubprocess.c
index e547fc6..e804421 100644
--- a/gio/gsubprocess.c
+++ b/gio/gsubprocess.c
@@ -1606,31 +1606,6 @@ g_subprocess_get_pid (GSubprocess *self)
return self->pid;
}
-/**
- * g_subprocess_add_watch:
- * @self: a #GSubprocess
- * @function: Callback invoked when child has exited
- * @user_data: Data for @function
- *
- * This function creates a source via g_subprocess_create_source() and
- * attaches it the to the <link
- * linkend="g-main-context-push-thread-default">thread-default main
- * loop</link>.
- *
- * For more information, see the documentation of
- * g_subprocess_add_watch_full().
- *
- * Returns: (transfer full): A newly-created #GSource for this process
- * Since: 2.34
- */
-GSource *
-g_subprocess_add_watch (GSubprocess *self,
- GSubprocessWatchFunc function,
- gpointer user_data)
-{
- return g_subprocess_add_watch_full (self, G_PRIORITY_DEFAULT, function, user_data, NULL);
-}
-
typedef struct {
GSubprocess *self;
GSubprocessWatchFunc callback;
@@ -1669,7 +1644,7 @@ g_subprocess_trampoline_data_destroy (gpointer user_data)
}
/**
- * g_subprocess_add_watch_full:
+ * g_subprocess_add_watch:
* @self: a #GSubprocess
* @priority: I/O priority
* @function: Callback invoked when child has exited
@@ -1677,9 +1652,7 @@ g_subprocess_trampoline_data_destroy (gpointer user_data)
* @notify: Destroy notify
*
* This function creates a source via g_subprocess_create_source() and
- * attaches it the to the <link
- * linkend="g-main-context-push-thread-default">thread-default main
- * loop</link>.
+ * attaches it the to the %NULL main context.
*
* Inside the callback, you should call either
* g_subprocess_query_success() or g_subprocess_get_exit_code() to
@@ -1688,22 +1661,24 @@ g_subprocess_trampoline_data_destroy (gpointer user_data)
* This function may not be used if g_subprocess_set_detached() has
* been called.
*
- * Returns: (transfer full): A newly-created #GSource for this process
+ * Returns: Integer identifier for this source in the %NULL main context
* Since: 2.34
*/
-GSource *
-g_subprocess_add_watch_full (GSubprocess *self,
- gint priority,
- GSubprocessWatchFunc function,
- gpointer user_data,
- GDestroyNotify notify)
+guint
+g_subprocess_add_watch (GSubprocess *self,
+ gint priority,
+ GSubprocessWatchFunc function,
+ gpointer user_data,
+ GDestroyNotify notify)
{
+ guint id;
GSource *source;
source = g_subprocess_create_source (self, priority, function, user_data, notify);
- g_source_attach (source, g_main_context_get_thread_default ());
+ id = g_source_attach (source, NULL);
+ g_source_unref (source);
- return source;
+ return id;
}
/**
@@ -1714,9 +1689,10 @@ g_subprocess_add_watch_full (GSubprocess *self,
* @user_data: Data for @function
* @notify: Destroy notify
*
- * This function is similar to g_child_watch_source_new(), except the
- * callback signature includes the subprocess @self, and status is
- * accessed via g_subprocess_query_success().
+ * This function is similar using g_child_watch_source_new(), except
+ * the callback signature includes the subprocess @self, and status is
+ * accessed via g_subprocess_query_success(). Do not call
+ * g_source_set_callback() on the returned source.
*
* This function may not be used if g_subprocess_set_detached() has
* been called.
@@ -1925,7 +1901,9 @@ g_subprocess_wait_sync (GSubprocess *self,
pushed_thread_default = TRUE;
loop = g_main_loop_new (context, TRUE);
- source = g_subprocess_add_watch (self, g_subprocess_on_sync_watch, loop);
+ source = g_subprocess_create_source (self, G_PRIORITY_DEFAULT,
+ g_subprocess_on_sync_watch, loop, NULL);
+ g_source_attach (source, g_main_context_get_thread_default ());
cancellable_source = g_cancellable_source_new (cancellable);
g_source_add_child_source (source, cancellable_source);
g_source_unref (cancellable_source);
diff --git a/gio/gsubprocess.h b/gio/gsubprocess.h
index cbd231c..b48af07 100644
--- a/gio/gsubprocess.h
+++ b/gio/gsubprocess.h
@@ -190,16 +190,11 @@ typedef void (*GSubprocessWatchFunc) (GSubprocess *subprocess,
gpointer user_data);
GLIB_AVAILABLE_IN_2_34
-GSource * g_subprocess_add_watch (GSubprocess *self,
- GSubprocessWatchFunc function,
- gpointer user_data);
-
-GLIB_AVAILABLE_IN_2_34
-GSource * g_subprocess_add_watch_full (GSubprocess *self,
- gint priority,
- GSubprocessWatchFunc function,
- gpointer user_data,
- GDestroyNotify notify);
+guint g_subprocess_add_watch (GSubprocess *self,
+ gint priority,
+ GSubprocessWatchFunc function,
+ gpointer user_data,
+ GDestroyNotify notify);
GLIB_AVAILABLE_IN_2_34
GSource * g_subprocess_create_source (GSubprocess *self,
diff --git a/gio/tests/gsubprocess.c b/gio/tests/gsubprocess.c
index da2d015..66ae52a 100644
--- a/gio/tests/gsubprocess.c
+++ b/gio/tests/gsubprocess.c
@@ -317,7 +317,6 @@ test_multi_1 (void)
GOutputStream *third_stdin;
GInputStream *third_stdout;
GOutputStream *membuf;
- GSource *proc_watch_source;
TestMultiSpliceData data;
int splice_flags = G_OUTPUT_STREAM_SPLICE_CLOSE_SOURCE | G_OUTPUT_STREAM_SPLICE_CLOSE_TARGET;
@@ -356,14 +355,14 @@ test_multi_1 (void)
g_timeout_add (250, on_idle_multisplice, &data);
data.events_pending++;
- proc_watch_source = g_subprocess_add_watch (first, on_subprocess_exited, &data);
- g_source_unref (proc_watch_source);
+ g_subprocess_add_watch (first, G_PRIORITY_DEFAULT, on_subprocess_exited,
+ &data, NULL);
data.events_pending++;
- proc_watch_source = g_subprocess_add_watch (second, on_subprocess_exited, &data);
- g_source_unref (proc_watch_source);
+ g_subprocess_add_watch (second, G_PRIORITY_DEFAULT, on_subprocess_exited,
+ &data, NULL);
data.events_pending++;
- proc_watch_source = g_subprocess_add_watch (third, on_subprocess_exited, &data);
- g_source_unref (proc_watch_source);
+ g_subprocess_add_watch (third, G_PRIORITY_DEFAULT, on_subprocess_exited,
+ &data, NULL);
g_main_loop_run (data.loop);
@@ -432,7 +431,6 @@ test_terminate (void)
GError *local_error = NULL;
GError **error = &local_error;
GMainLoop *loop;
- GSource *source;
proc = get_test_subprocess ("sleep-forever");
@@ -441,8 +439,8 @@ test_terminate (void)
loop = g_main_loop_new (NULL, TRUE);
- source = g_subprocess_add_watch (proc, on_request_quit_exited, loop);
- g_source_unref (source);
+ (void) g_subprocess_add_watch (proc, G_PRIORITY_DEFAULT, on_request_quit_exited,
+ loop, NULL);
g_timeout_add_seconds (3, send_terminate, proc);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]