Improve GSimpleActionGroup test coverage
[platform/upstream/glib.git] / gio / gtask.h
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 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, write to the
17  * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
18  * Boston, MA 02111-1307, USA.
19  */
20
21 #ifndef __G_TASK_H__
22 #define __G_TASK_H__
23
24 #if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
25 #error "Only <gio/gio.h> can be included directly."
26 #endif
27
28 #include <gio/giotypes.h>
29
30 G_BEGIN_DECLS
31
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))
38
39 typedef struct _GTaskClass   GTaskClass;
40
41 GLIB_AVAILABLE_IN_2_36
42 GType         g_task_get_type              (void) G_GNUC_CONST;
43
44 GLIB_AVAILABLE_IN_2_36
45 GTask        *g_task_new                   (gpointer             source_object,
46                                             GCancellable        *cancellable,
47                                             GAsyncReadyCallback  callback,
48                                             gpointer             callback_data);
49
50 GLIB_AVAILABLE_IN_2_36
51 void          g_task_report_error          (gpointer             source_object,
52                                             GAsyncReadyCallback  callback,
53                                             gpointer             callback_data,
54                                             gpointer             source_tag,
55                                             GError              *error);
56 GLIB_AVAILABLE_IN_2_36
57 void          g_task_report_new_error      (gpointer             source_object,
58                                             GAsyncReadyCallback  callback,
59                                             gpointer             callback_data,
60                                             gpointer             source_tag,
61                                             GQuark               domain,
62                                             gint                 code,
63                                             const char          *format,
64                                             ...) G_GNUC_PRINTF(7, 8);
65
66 GLIB_AVAILABLE_IN_2_36
67 void          g_task_set_task_data         (GTask               *task,
68                                             gpointer             task_data,
69                                             GDestroyNotify       task_data_destroy);
70 GLIB_AVAILABLE_IN_2_36
71 void          g_task_set_priority          (GTask               *task,
72                                             gint                 priority);
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,
78                                             gpointer             source_tag);
79
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);
94
95 GLIB_AVAILABLE_IN_2_36
96 gboolean      g_task_is_valid              (gpointer             result,
97                                             gpointer             source_object);
98
99
100 typedef void (*GTaskThreadFunc)           (GTask           *task,
101                                            gpointer         source_object,
102                                            gpointer         task_data,
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);
115
116 GLIB_AVAILABLE_IN_2_36
117 void          g_task_attach_source        (GTask           *task,
118                                            GSource         *source,
119                                            GSourceFunc      callback);
120
121
122 GLIB_AVAILABLE_IN_2_36
123 void          g_task_return_pointer            (GTask           *task,
124                                                 gpointer         result,
125                                                 GDestroyNotify   result_destroy);
126 GLIB_AVAILABLE_IN_2_36
127 void          g_task_return_boolean            (GTask           *task,
128                                                 gboolean         result);
129 GLIB_AVAILABLE_IN_2_36
130 void          g_task_return_int                (GTask           *task,
131                                                 gssize           result);
132
133 GLIB_AVAILABLE_IN_2_36
134 void          g_task_return_error              (GTask           *task,
135                                                 GError          *error);
136 GLIB_AVAILABLE_IN_2_36
137 void          g_task_return_new_error          (GTask           *task,
138                                                 GQuark           domain,
139                                                 gint             code,
140                                                 const char      *format,
141                                                 ...) G_GNUC_PRINTF (4, 5);
142
143 GLIB_AVAILABLE_IN_2_36
144 gboolean      g_task_return_error_if_cancelled (GTask           *task);
145
146 GLIB_AVAILABLE_IN_2_36
147 gpointer      g_task_propagate_pointer         (GTask           *task,
148                                                 GError         **error);
149 GLIB_AVAILABLE_IN_2_36
150 gboolean      g_task_propagate_boolean         (GTask           *task,
151                                                 GError         **error);
152 GLIB_AVAILABLE_IN_2_36
153 gssize        g_task_propagate_int             (GTask           *task,
154                                                 GError         **error);
155 GLIB_AVAILABLE_IN_2_36
156 gboolean      g_task_had_error                 (GTask           *task);
157
158 G_END_DECLS
159
160 #endif /* __G_TASK_H__ */