1 | /* GIO - GLib Input, Output and Streaming Library |
2 | * |
3 | * Copyright 2011 Red Hat, Inc. |
4 | * |
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.1 of the License, or (at your option) any later version. |
9 | * |
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. |
14 | * |
15 | * You should have received a copy of the GNU Lesser General |
16 | * Public License along with this library; if not, see <http://www.gnu.org/licenses/>. |
17 | */ |
18 | |
19 | #ifndef __G_TASK_H__ |
20 | #define __G_TASK_H__ |
21 | |
22 | #if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) |
23 | #error "Only <gio/gio.h> can be included directly." |
24 | #endif |
25 | |
26 | #include <gio/giotypes.h> |
27 | |
28 | G_BEGIN_DECLS |
29 | |
30 | #define G_TYPE_TASK (g_task_get_type ()) |
31 | #define G_TASK(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_TASK, GTask)) |
32 | #define G_TASK_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_TASK, GTaskClass)) |
33 | #define G_IS_TASK(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_TASK)) |
34 | #define G_IS_TASK_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_TASK)) |
35 | #define G_TASK_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_TASK, GTaskClass)) |
36 | |
37 | typedef struct _GTaskClass GTaskClass; |
38 | |
39 | GLIB_AVAILABLE_IN_2_36 |
40 | GType g_task_get_type (void) G_GNUC_CONST; |
41 | |
42 | GLIB_AVAILABLE_IN_2_36 |
43 | GTask *g_task_new (gpointer source_object, |
44 | GCancellable *cancellable, |
45 | GAsyncReadyCallback callback, |
46 | gpointer callback_data); |
47 | |
48 | GLIB_AVAILABLE_IN_2_36 |
49 | void g_task_report_error (gpointer source_object, |
50 | GAsyncReadyCallback callback, |
51 | gpointer callback_data, |
52 | gpointer source_tag, |
53 | GError *error); |
54 | GLIB_AVAILABLE_IN_2_36 |
55 | void g_task_report_new_error (gpointer source_object, |
56 | GAsyncReadyCallback callback, |
57 | gpointer callback_data, |
58 | gpointer source_tag, |
59 | GQuark domain, |
60 | gint code, |
61 | const char *format, |
62 | ...) G_GNUC_PRINTF(7, 8); |
63 | |
64 | GLIB_AVAILABLE_IN_2_36 |
65 | void g_task_set_task_data (GTask *task, |
66 | gpointer task_data, |
67 | GDestroyNotify task_data_destroy); |
68 | GLIB_AVAILABLE_IN_2_36 |
69 | void g_task_set_priority (GTask *task, |
70 | gint priority); |
71 | GLIB_AVAILABLE_IN_2_36 |
72 | void g_task_set_check_cancellable (GTask *task, |
73 | gboolean check_cancellable); |
74 | GLIB_AVAILABLE_IN_2_36 |
75 | void g_task_set_source_tag (GTask *task, |
76 | gpointer source_tag); |
77 | GLIB_AVAILABLE_IN_2_60 |
78 | void g_task_set_name (GTask *task, |
79 | const gchar *name); |
80 | |
81 | GLIB_AVAILABLE_IN_2_36 |
82 | gpointer g_task_get_source_object (GTask *task); |
83 | GLIB_AVAILABLE_IN_2_36 |
84 | gpointer g_task_get_task_data (GTask *task); |
85 | GLIB_AVAILABLE_IN_2_36 |
86 | gint g_task_get_priority (GTask *task); |
87 | GLIB_AVAILABLE_IN_2_36 |
88 | GMainContext *g_task_get_context (GTask *task); |
89 | GLIB_AVAILABLE_IN_2_36 |
90 | GCancellable *g_task_get_cancellable (GTask *task); |
91 | GLIB_AVAILABLE_IN_2_36 |
92 | gboolean g_task_get_check_cancellable (GTask *task); |
93 | GLIB_AVAILABLE_IN_2_36 |
94 | gpointer g_task_get_source_tag (GTask *task); |
95 | GLIB_AVAILABLE_IN_2_60 |
96 | const gchar *g_task_get_name (GTask *task); |
97 | |
98 | GLIB_AVAILABLE_IN_2_36 |
99 | gboolean g_task_is_valid (gpointer result, |
100 | gpointer source_object); |
101 | |
102 | |
103 | typedef void (*GTaskThreadFunc) (GTask *task, |
104 | gpointer source_object, |
105 | gpointer task_data, |
106 | GCancellable *cancellable); |
107 | GLIB_AVAILABLE_IN_2_36 |
108 | void g_task_run_in_thread (GTask *task, |
109 | GTaskThreadFunc task_func); |
110 | GLIB_AVAILABLE_IN_2_36 |
111 | void g_task_run_in_thread_sync (GTask *task, |
112 | GTaskThreadFunc task_func); |
113 | GLIB_AVAILABLE_IN_2_36 |
114 | gboolean g_task_set_return_on_cancel (GTask *task, |
115 | gboolean return_on_cancel); |
116 | GLIB_AVAILABLE_IN_2_36 |
117 | gboolean g_task_get_return_on_cancel (GTask *task); |
118 | |
119 | GLIB_AVAILABLE_IN_2_36 |
120 | void g_task_attach_source (GTask *task, |
121 | GSource *source, |
122 | GSourceFunc callback); |
123 | |
124 | |
125 | GLIB_AVAILABLE_IN_2_36 |
126 | void g_task_return_pointer (GTask *task, |
127 | gpointer result, |
128 | GDestroyNotify result_destroy); |
129 | GLIB_AVAILABLE_IN_2_36 |
130 | void g_task_return_boolean (GTask *task, |
131 | gboolean result); |
132 | GLIB_AVAILABLE_IN_2_36 |
133 | void g_task_return_int (GTask *task, |
134 | gssize result); |
135 | |
136 | GLIB_AVAILABLE_IN_2_36 |
137 | void g_task_return_error (GTask *task, |
138 | GError *error); |
139 | GLIB_AVAILABLE_IN_2_36 |
140 | void g_task_return_new_error (GTask *task, |
141 | GQuark domain, |
142 | gint code, |
143 | const char *format, |
144 | ...) G_GNUC_PRINTF (4, 5); |
145 | |
146 | GLIB_AVAILABLE_IN_2_36 |
147 | gboolean g_task_return_error_if_cancelled (GTask *task); |
148 | |
149 | GLIB_AVAILABLE_IN_2_36 |
150 | gpointer g_task_propagate_pointer (GTask *task, |
151 | GError **error); |
152 | GLIB_AVAILABLE_IN_2_36 |
153 | gboolean g_task_propagate_boolean (GTask *task, |
154 | GError **error); |
155 | GLIB_AVAILABLE_IN_2_36 |
156 | gssize g_task_propagate_int (GTask *task, |
157 | GError **error); |
158 | GLIB_AVAILABLE_IN_2_36 |
159 | gboolean g_task_had_error (GTask *task); |
160 | GLIB_AVAILABLE_IN_2_44 |
161 | gboolean g_task_get_completed (GTask *task); |
162 | |
163 | G_END_DECLS |
164 | |
165 | #endif /* __G_TASK_H__ */ |
166 | |