cleanup
[platform/upstream/glib.git] / gio / gsocketaddressenumerator.c
index 2193860..51ca4a5 100644 (file)
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
  */
 
 #include "config.h"
 #include "gsocketaddressenumerator.h"
 #include "glibintl.h"
 
-#include "gsimpleasyncresult.h"
+#include "gtask.h"
 
 
 G_DEFINE_ABSTRACT_TYPE (GSocketAddressEnumerator, g_socket_address_enumerator, G_TYPE_OBJECT);
@@ -67,7 +65,7 @@ g_socket_address_enumerator_class_init (GSocketAddressEnumeratorClass *enumerato
  * internal errors (other than @cancellable being triggered) will be
  * ignored.
  *
- * Return value: (transfer full): a #GSocketAddress (owned by the caller), or %NULL on
+ * Returns: (transfer full): a #GSocketAddress (owned by the caller), or %NULL on
  *     error (in which case *@error will be set) or if there are no
  *     more addresses.
  */
@@ -95,21 +93,19 @@ g_socket_address_enumerator_real_next_async (GSocketAddressEnumerator *enumerato
                                             GAsyncReadyCallback       callback,
                                             gpointer                  user_data)
 {
-  GSimpleAsyncResult *result;
+  GTask *task;
   GSocketAddress *address;
   GError *error = NULL;
 
-  result = g_simple_async_result_new (G_OBJECT (enumerator),
-                                     callback, user_data,
-                                     g_socket_address_enumerator_real_next_async);
+  task = g_task_new (enumerator, NULL, callback, user_data);
+
   address = g_socket_address_enumerator_next (enumerator, cancellable, &error);
-  if (address)
-    g_simple_async_result_set_op_res_gpointer (result, address, NULL);
-  else if (error)
-    g_simple_async_result_take_error (result, error);
+  if (error)
+    g_task_return_error (task, error);
+  else
+    g_task_return_pointer (task, address, g_object_unref);
 
-  g_simple_async_result_complete_in_idle (result);
-  g_object_unref (result);
+  g_object_unref (task);
 }
 
 /**
@@ -144,16 +140,9 @@ g_socket_address_enumerator_real_next_finish (GSocketAddressEnumerator  *enumera
                                              GAsyncResult              *result,
                                              GError                   **error)
 {
-  GSimpleAsyncResult *simple;
+  g_return_val_if_fail (g_task_is_valid (result, enumerator), NULL);
 
-  g_return_val_if_fail (G_IS_SIMPLE_ASYNC_RESULT (result), NULL);
-  simple = G_SIMPLE_ASYNC_RESULT (result);
-  g_return_val_if_fail (g_simple_async_result_get_source_tag (simple) == g_socket_address_enumerator_real_next_async, NULL);
-
-  if (g_simple_async_result_propagate_error (simple, error))
-    return NULL;
-  else
-    return g_simple_async_result_get_op_res_gpointer (simple);
+  return g_task_propagate_pointer (G_TASK (result), error);
 }
 
 /**
@@ -167,7 +156,7 @@ g_socket_address_enumerator_real_next_finish (GSocketAddressEnumerator  *enumera
  * g_socket_address_enumerator_next() for more information about
  * error handling.
  *
- * Return value: (transfer full): a #GSocketAddress (owned by the caller), or %NULL on
+ * Returns: (transfer full): a #GSocketAddress (owned by the caller), or %NULL on
  *     error (in which case *@error will be set) or if there are no
  *     more addresses.
  */