1 /* GIO - GLib Input, Output and Streaming Library
3 * Copyright (C) 2006-2007 Red Hat, Inc.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General
16 * Public License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
18 * Boston, MA 02111-1307, USA.
20 * Author: Alexander Larsson <alexl@redhat.com>
23 #ifndef __G_SIMPLE_ASYNC_RESULT_H__
24 #define __G_SIMPLE_ASYNC_RESULT_H__
26 #include <gio/gasyncresult.h>
27 #include <gio/gcancellable.h>
31 #define G_TYPE_SIMPLE_ASYNC_RESULT (g_simple_async_result_get_type ())
32 #define G_SIMPLE_ASYNC_RESULT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_SIMPLE_ASYNC_RESULT, GSimpleAsyncResult))
33 #define G_SIMPLE_ASYNC_RESULT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_SIMPLE_ASYNC_RESULT, GSimpleAsyncResultClass))
34 #define G_IS_SIMPLE_ASYNC_RESULT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_SIMPLE_ASYNC_RESULT))
35 #define G_IS_SIMPLE_ASYNC_RESULT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_SIMPLE_ASYNC_RESULT))
36 #define G_SIMPLE_ASYNC_RESULT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_SIMPLE_ASYNC_RESULT, GSimpleAsyncResultClass))
41 * A simple implementation of #GAsyncResult.
43 typedef struct _GSimpleAsyncResult GSimpleAsyncResult;
44 typedef struct _GSimpleAsyncResultClass GSimpleAsyncResultClass;
47 * GSimpleAsyncThreadFunc:
48 * @res: a #GSimpleAsyncResult.
49 * @object: a #GObject.
50 * @cancellable: optional #GCancellable object, %NULL to ignore.
52 * Simple thread function that runs an asynchronous operation and
53 * checks for cancellation.
55 typedef void (*GSimpleAsyncThreadFunc) (GSimpleAsyncResult *res,
57 GCancellable *cancellable);
60 GType g_simple_async_result_get_type (void) G_GNUC_CONST;
62 GSimpleAsyncResult *g_simple_async_result_new (GObject *source_object,
63 GAsyncReadyCallback callback,
66 GSimpleAsyncResult *g_simple_async_result_new_error (GObject *source_object,
67 GAsyncReadyCallback callback,
72 ...) G_GNUC_PRINTF (6, 7);
73 GSimpleAsyncResult *g_simple_async_result_new_from_error (GObject *source_object,
74 GAsyncReadyCallback callback,
78 void g_simple_async_result_set_op_res_gpointer (GSimpleAsyncResult *simple,
80 GDestroyNotify destroy_op_res);
81 gpointer g_simple_async_result_get_op_res_gpointer (GSimpleAsyncResult *simple);
83 void g_simple_async_result_set_op_res_gssize (GSimpleAsyncResult *simple,
85 gssize g_simple_async_result_get_op_res_gssize (GSimpleAsyncResult *simple);
87 void g_simple_async_result_set_op_res_gboolean (GSimpleAsyncResult *simple,
89 gboolean g_simple_async_result_get_op_res_gboolean (GSimpleAsyncResult *simple);
93 gpointer g_simple_async_result_get_source_tag (GSimpleAsyncResult *simple);
94 void g_simple_async_result_set_handle_cancellation (GSimpleAsyncResult *simple,
95 gboolean handle_cancellation);
96 void g_simple_async_result_complete (GSimpleAsyncResult *simple);
97 void g_simple_async_result_complete_in_idle (GSimpleAsyncResult *simple);
98 void g_simple_async_result_run_in_thread (GSimpleAsyncResult *simple,
99 GSimpleAsyncThreadFunc func,
101 GCancellable *cancellable);
102 void g_simple_async_result_set_from_error (GSimpleAsyncResult *simple,
104 gboolean g_simple_async_result_propagate_error (GSimpleAsyncResult *simple,
106 void g_simple_async_result_set_error (GSimpleAsyncResult *simple,
110 ...) G_GNUC_PRINTF (4, 5);
111 void g_simple_async_result_set_error_va (GSimpleAsyncResult *simple,
117 void g_simple_async_report_error_in_idle (GObject *object,
118 GAsyncReadyCallback callback,
124 void g_simple_async_report_gerror_in_idle (GObject *object,
125 GAsyncReadyCallback callback,
133 #endif /* __G_SIMPLE_ASYNC_RESULT_H__ */