1 /* GIO - GLib Input, Output and Streaming Library
3 * Copyright 2011 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.
24 #if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
25 #error "Only <gio/gio.h> can be included directly."
28 #include <gio/giotypes.h>
32 #define G_TYPE_TASK (g_task_get_type ())
33 #define G_TASK(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_TASK, GTask))
34 #define G_TASK_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_TASK, GTaskClass))
35 #define G_IS_TASK(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_TASK))
36 #define G_IS_TASK_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_TASK))
37 #define G_TASK_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_TASK, GTaskClass))
39 typedef struct _GTaskClass GTaskClass;
41 GLIB_AVAILABLE_IN_2_36
42 GType g_task_get_type (void) G_GNUC_CONST;
44 GLIB_AVAILABLE_IN_2_36
45 GTask *g_task_new (gpointer source_object,
46 GCancellable *cancellable,
47 GAsyncReadyCallback callback,
48 gpointer callback_data);
50 GLIB_AVAILABLE_IN_2_36
51 void g_task_report_error (gpointer source_object,
52 GAsyncReadyCallback callback,
53 gpointer callback_data,
56 GLIB_AVAILABLE_IN_2_36
57 void g_task_report_new_error (gpointer source_object,
58 GAsyncReadyCallback callback,
59 gpointer callback_data,
64 ...) G_GNUC_PRINTF(7, 8);
66 GLIB_AVAILABLE_IN_2_36
67 void g_task_set_task_data (GTask *task,
69 GDestroyNotify task_data_destroy);
70 GLIB_AVAILABLE_IN_2_36
71 void g_task_set_priority (GTask *task,
73 GLIB_AVAILABLE_IN_2_36
74 void g_task_set_check_cancellable (GTask *task,
75 gboolean check_cancellable);
76 GLIB_AVAILABLE_IN_2_36
77 void g_task_set_source_tag (GTask *task,
80 GLIB_AVAILABLE_IN_2_36
81 gpointer g_task_get_source_object (GTask *task);
82 GLIB_AVAILABLE_IN_2_36
83 gpointer g_task_get_task_data (GTask *task);
84 GLIB_AVAILABLE_IN_2_36
85 gint g_task_get_priority (GTask *task);
86 GLIB_AVAILABLE_IN_2_36
87 GMainContext *g_task_get_context (GTask *task);
88 GLIB_AVAILABLE_IN_2_36
89 GCancellable *g_task_get_cancellable (GTask *task);
90 GLIB_AVAILABLE_IN_2_36
91 gboolean g_task_get_check_cancellable (GTask *task);
92 GLIB_AVAILABLE_IN_2_36
93 gpointer g_task_get_source_tag (GTask *task);
95 GLIB_AVAILABLE_IN_2_36
96 gboolean g_task_is_valid (gpointer result,
97 gpointer source_object);
100 typedef void (*GTaskThreadFunc) (GTask *task,
101 gpointer source_object,
103 GCancellable *cancellable);
104 GLIB_AVAILABLE_IN_2_36
105 void g_task_run_in_thread (GTask *task,
106 GTaskThreadFunc task_func);
107 GLIB_AVAILABLE_IN_2_36
108 void g_task_run_in_thread_sync (GTask *task,
109 GTaskThreadFunc task_func);
110 GLIB_AVAILABLE_IN_2_36
111 gboolean g_task_set_return_on_cancel (GTask *task,
112 gboolean return_on_cancel);
113 GLIB_AVAILABLE_IN_2_36
114 gboolean g_task_get_return_on_cancel (GTask *task);
116 GLIB_AVAILABLE_IN_2_36
117 void g_task_attach_source (GTask *task,
119 GSourceFunc callback);
122 GLIB_AVAILABLE_IN_2_36
123 void g_task_return_pointer (GTask *task,
125 GDestroyNotify result_destroy);
126 GLIB_AVAILABLE_IN_2_36
127 void g_task_return_boolean (GTask *task,
129 GLIB_AVAILABLE_IN_2_36
130 void g_task_return_int (GTask *task,
133 GLIB_AVAILABLE_IN_2_36
134 void g_task_return_error (GTask *task,
136 GLIB_AVAILABLE_IN_2_36
137 void g_task_return_new_error (GTask *task,
141 ...) G_GNUC_PRINTF (4, 5);
143 GLIB_AVAILABLE_IN_2_36
144 gboolean g_task_return_error_if_cancelled (GTask *task);
146 GLIB_AVAILABLE_IN_2_36
147 gpointer g_task_propagate_pointer (GTask *task,
149 GLIB_AVAILABLE_IN_2_36
150 gboolean g_task_propagate_boolean (GTask *task,
152 GLIB_AVAILABLE_IN_2_36
153 gssize g_task_propagate_int (GTask *task,
155 GLIB_AVAILABLE_IN_2_36
156 gboolean g_task_had_error (GTask *task);
160 #endif /* __G_TASK_H__ */