[libsoup/wip/remove-deprecations: 59/77] Add soup_add_timeout_reffed()




commit 70bb9d6f941624d138d09397d87aeb7d80d4ac02
Author: Dan Winship <danw gnome org>
Date:   Sun Dec 7 21:17:26 2014 +0100

    Add soup_add_timeout_reffed()

 libsoup/soup-misc.c | 17 ++++++++++++++---
 libsoup/soup-misc.h |  5 +++++
 2 files changed, 19 insertions(+), 3 deletions(-)
---
diff --git a/libsoup/soup-misc.c b/libsoup/soup-misc.c
index a0df9c56..f1e954ac 100644
--- a/libsoup/soup-misc.c
+++ b/libsoup/soup-misc.c
@@ -155,6 +155,17 @@ soup_add_completion (GMainContext *async_context,
        return source;
 }
 
+GSource *
+soup_add_timeout_reffed (GMainContext *async_context,
+                        guint interval,
+                        GSourceFunc function, gpointer data)
+{
+       GSource *source = g_timeout_source_new (interval);
+       g_source_set_callback (source, function, data, NULL);
+       g_source_attach (source, async_context);
+       return source;
+}
+
 /**
  * soup_add_timeout: (skip)
  * @async_context: (allow-none): the #GMainContext to dispatch the I/O
@@ -174,9 +185,9 @@ soup_add_timeout (GMainContext *async_context,
                  guint interval,
                  GSourceFunc function, gpointer data)
 {
-       GSource *source = g_timeout_source_new (interval);
-       g_source_set_callback (source, function, data, NULL);
-       g_source_attach (source, async_context);
+       GSource *source;
+
+       source = soup_add_timeout_reffed (async_context, interval, function, data);
        g_source_unref (source);
        return source;
 }
diff --git a/libsoup/soup-misc.h b/libsoup/soup-misc.h
index ab5dff0c..57800349 100644
--- a/libsoup/soup-misc.h
+++ b/libsoup/soup-misc.h
@@ -78,6 +78,11 @@ GSource *soup_add_completion_reffed (GMainContext   *async_context,
                                     gpointer        data,
                                     GDestroyNotify  dnotify);
 
+GSource *soup_add_timeout_reffed (GMainContext *async_context,
+                                 guint         interval,
+                                 GSourceFunc   function,
+                                 gpointer      data);
+
 guint soup_message_headers_get_ranges_internal (SoupMessageHeaders  *hdrs,
                                                goffset              total_length,
                                                gboolean             check_satisfiable,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]