File indexing completed on 2025-01-18 10:00:00
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021 #ifndef __G_TASK_H__
0022 #define __G_TASK_H__
0023
0024 #if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
0025 #error "Only <gio/gio.h> can be included directly."
0026 #endif
0027
0028 #include <gio/giotypes.h>
0029
0030 G_BEGIN_DECLS
0031
0032 #define G_TYPE_TASK (g_task_get_type ())
0033 #define G_TASK(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_TASK, GTask))
0034 #define G_TASK_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_TASK, GTaskClass))
0035 #define G_IS_TASK(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_TASK))
0036 #define G_IS_TASK_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_TASK))
0037 #define G_TASK_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_TASK, GTaskClass))
0038
0039 typedef struct _GTaskClass GTaskClass;
0040
0041 GIO_AVAILABLE_IN_2_36
0042 GType g_task_get_type (void) G_GNUC_CONST;
0043
0044 GIO_AVAILABLE_IN_2_36
0045 GTask *g_task_new (gpointer source_object,
0046 GCancellable *cancellable,
0047 GAsyncReadyCallback callback,
0048 gpointer callback_data);
0049
0050 GIO_AVAILABLE_IN_2_36
0051 void g_task_report_error (gpointer source_object,
0052 GAsyncReadyCallback callback,
0053 gpointer callback_data,
0054 gpointer source_tag,
0055 GError *error);
0056 GIO_AVAILABLE_IN_2_36
0057 void g_task_report_new_error (gpointer source_object,
0058 GAsyncReadyCallback callback,
0059 gpointer callback_data,
0060 gpointer source_tag,
0061 GQuark domain,
0062 gint code,
0063 const char *format,
0064 ...) G_GNUC_PRINTF(7, 8);
0065
0066 GIO_AVAILABLE_IN_2_36
0067 void g_task_set_task_data (GTask *task,
0068 gpointer task_data,
0069 GDestroyNotify task_data_destroy);
0070 GIO_AVAILABLE_IN_2_36
0071 void g_task_set_priority (GTask *task,
0072 gint priority);
0073 GIO_AVAILABLE_IN_2_36
0074 void g_task_set_check_cancellable (GTask *task,
0075 gboolean check_cancellable);
0076 GIO_AVAILABLE_IN_2_36
0077 void g_task_set_source_tag (GTask *task,
0078 gpointer source_tag);
0079 GIO_AVAILABLE_IN_2_60
0080 void g_task_set_name (GTask *task,
0081 const gchar *name);
0082 GIO_AVAILABLE_IN_2_76
0083 void g_task_set_static_name (GTask *task,
0084 const gchar *name);
0085
0086
0087 #if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_76
0088 #define g_task_set_source_tag(task, tag) G_STMT_START { \
0089 GTask *_task = (task); \
0090 (g_task_set_source_tag) (_task, tag); \
0091 if (g_task_get_name (_task) == NULL) \
0092 g_task_set_static_name (_task, G_STRINGIFY (tag)); \
0093 } G_STMT_END
0094 #endif
0095
0096 #if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_76
0097 #if defined (__GNUC__) && (__GNUC__ >= 2)
0098 #define g_task_set_name(task, name) G_STMT_START { \
0099 GTask *_task = (task); \
0100 if (__builtin_constant_p (name)) \
0101 g_task_set_static_name (_task, name); \
0102 else \
0103 g_task_set_name (_task, name); \
0104 } G_STMT_END
0105 #endif
0106 #endif
0107
0108 GIO_AVAILABLE_IN_2_36
0109 gpointer g_task_get_source_object (GTask *task);
0110 GIO_AVAILABLE_IN_2_36
0111 gpointer g_task_get_task_data (GTask *task);
0112 GIO_AVAILABLE_IN_2_36
0113 gint g_task_get_priority (GTask *task);
0114 GIO_AVAILABLE_IN_2_36
0115 GMainContext *g_task_get_context (GTask *task);
0116 GIO_AVAILABLE_IN_2_36
0117 GCancellable *g_task_get_cancellable (GTask *task);
0118 GIO_AVAILABLE_IN_2_36
0119 gboolean g_task_get_check_cancellable (GTask *task);
0120 GIO_AVAILABLE_IN_2_36
0121 gpointer g_task_get_source_tag (GTask *task);
0122 GIO_AVAILABLE_IN_2_60
0123 const gchar *g_task_get_name (GTask *task);
0124
0125 GIO_AVAILABLE_IN_2_36
0126 gboolean g_task_is_valid (gpointer result,
0127 gpointer source_object);
0128
0129
0130 typedef void (*GTaskThreadFunc) (GTask *task,
0131 gpointer source_object,
0132 gpointer task_data,
0133 GCancellable *cancellable);
0134 GIO_AVAILABLE_IN_2_36
0135 void g_task_run_in_thread (GTask *task,
0136 GTaskThreadFunc task_func);
0137 GIO_AVAILABLE_IN_2_36
0138 void g_task_run_in_thread_sync (GTask *task,
0139 GTaskThreadFunc task_func);
0140 GIO_AVAILABLE_IN_2_36
0141 gboolean g_task_set_return_on_cancel (GTask *task,
0142 gboolean return_on_cancel);
0143 GIO_AVAILABLE_IN_2_36
0144 gboolean g_task_get_return_on_cancel (GTask *task);
0145
0146 GIO_AVAILABLE_IN_2_36
0147 void g_task_attach_source (GTask *task,
0148 GSource *source,
0149 GSourceFunc callback);
0150
0151
0152 GIO_AVAILABLE_IN_2_36
0153 void g_task_return_pointer (GTask *task,
0154 gpointer result,
0155 GDestroyNotify result_destroy);
0156 GIO_AVAILABLE_IN_2_36
0157 void g_task_return_boolean (GTask *task,
0158 gboolean result);
0159 GIO_AVAILABLE_IN_2_36
0160 void g_task_return_int (GTask *task,
0161 gssize result);
0162
0163 GIO_AVAILABLE_IN_2_36
0164 void g_task_return_error (GTask *task,
0165 GError *error);
0166 GIO_AVAILABLE_IN_2_80
0167 void g_task_return_prefixed_error (GTask *task,
0168 GError *error,
0169 const char *format,
0170 ...) G_GNUC_PRINTF (3, 4);
0171
0172 GIO_AVAILABLE_IN_2_36
0173 void g_task_return_new_error (GTask *task,
0174 GQuark domain,
0175 gint code,
0176 const char *format,
0177 ...) G_GNUC_PRINTF (4, 5);
0178
0179 GIO_AVAILABLE_IN_2_80
0180 void g_task_return_new_error_literal (GTask *task,
0181 GQuark domain,
0182 gint code,
0183 const char *message);
0184 GIO_AVAILABLE_IN_2_64
0185 void g_task_return_value (GTask *task,
0186 GValue *result);
0187
0188 GIO_AVAILABLE_IN_2_36
0189 gboolean g_task_return_error_if_cancelled (GTask *task);
0190
0191 GIO_AVAILABLE_IN_2_36
0192 gpointer g_task_propagate_pointer (GTask *task,
0193 GError **error);
0194 GIO_AVAILABLE_IN_2_36
0195 gboolean g_task_propagate_boolean (GTask *task,
0196 GError **error);
0197 GIO_AVAILABLE_IN_2_36
0198 gssize g_task_propagate_int (GTask *task,
0199 GError **error);
0200 GIO_AVAILABLE_IN_2_64
0201 gboolean g_task_propagate_value (GTask *task,
0202 GValue *value,
0203 GError **error);
0204 GIO_AVAILABLE_IN_2_36
0205 gboolean g_task_had_error (GTask *task);
0206 GIO_AVAILABLE_IN_2_44
0207 gboolean g_task_get_completed (GTask *task);
0208
0209
0210 #ifndef __GTK_DOC_IGNORE__
0211 #ifndef __GI_SCANNER__
0212
0213 void g_task_print_alive_tasks (void);
0214 #endif
0215 #endif
0216
0217 G_END_DECLS
0218
0219 #endif