gtask.h 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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, see <http://www.gnu.org/licenses/>.
  17. */
  18. #ifndef __G_TASK_H__
  19. #define __G_TASK_H__
  20. #if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
  21. #error "Only <gio/gio.h> can be included directly."
  22. #endif
  23. #include <gio/giotypes.h>
  24. G_BEGIN_DECLS
  25. #define G_TYPE_TASK (g_task_get_type ())
  26. #define G_TASK(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_TASK, GTask))
  27. #define G_TASK_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_TASK, GTaskClass))
  28. #define G_IS_TASK(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_TASK))
  29. #define G_IS_TASK_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_TASK))
  30. #define G_TASK_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_TASK, GTaskClass))
  31. typedef struct _GTaskClass GTaskClass;
  32. GLIB_AVAILABLE_IN_2_36
  33. GType g_task_get_type (void) G_GNUC_CONST;
  34. GLIB_AVAILABLE_IN_2_36
  35. GTask *g_task_new (gpointer source_object,
  36. GCancellable *cancellable,
  37. GAsyncReadyCallback callback,
  38. gpointer callback_data);
  39. GLIB_AVAILABLE_IN_2_36
  40. void g_task_report_error (gpointer source_object,
  41. GAsyncReadyCallback callback,
  42. gpointer callback_data,
  43. gpointer source_tag,
  44. GError *error);
  45. GLIB_AVAILABLE_IN_2_36
  46. void g_task_report_new_error (gpointer source_object,
  47. GAsyncReadyCallback callback,
  48. gpointer callback_data,
  49. gpointer source_tag,
  50. GQuark domain,
  51. gint code,
  52. const char *format,
  53. ...) G_GNUC_PRINTF(7, 8);
  54. GLIB_AVAILABLE_IN_2_36
  55. void g_task_set_task_data (GTask *task,
  56. gpointer task_data,
  57. GDestroyNotify task_data_destroy);
  58. GLIB_AVAILABLE_IN_2_36
  59. void g_task_set_priority (GTask *task,
  60. gint priority);
  61. GLIB_AVAILABLE_IN_2_36
  62. void g_task_set_check_cancellable (GTask *task,
  63. gboolean check_cancellable);
  64. GLIB_AVAILABLE_IN_2_36
  65. void g_task_set_source_tag (GTask *task,
  66. gpointer source_tag);
  67. GLIB_AVAILABLE_IN_2_36
  68. gpointer g_task_get_source_object (GTask *task);
  69. GLIB_AVAILABLE_IN_2_36
  70. gpointer g_task_get_task_data (GTask *task);
  71. GLIB_AVAILABLE_IN_2_36
  72. gint g_task_get_priority (GTask *task);
  73. GLIB_AVAILABLE_IN_2_36
  74. GMainContext *g_task_get_context (GTask *task);
  75. GLIB_AVAILABLE_IN_2_36
  76. GCancellable *g_task_get_cancellable (GTask *task);
  77. GLIB_AVAILABLE_IN_2_36
  78. gboolean g_task_get_check_cancellable (GTask *task);
  79. GLIB_AVAILABLE_IN_2_36
  80. gpointer g_task_get_source_tag (GTask *task);
  81. GLIB_AVAILABLE_IN_2_36
  82. gboolean g_task_is_valid (gpointer result,
  83. gpointer source_object);
  84. typedef void (*GTaskThreadFunc) (GTask *task,
  85. gpointer source_object,
  86. gpointer task_data,
  87. GCancellable *cancellable);
  88. GLIB_AVAILABLE_IN_2_36
  89. void g_task_run_in_thread (GTask *task,
  90. GTaskThreadFunc task_func);
  91. GLIB_AVAILABLE_IN_2_36
  92. void g_task_run_in_thread_sync (GTask *task,
  93. GTaskThreadFunc task_func);
  94. GLIB_AVAILABLE_IN_2_36
  95. gboolean g_task_set_return_on_cancel (GTask *task,
  96. gboolean return_on_cancel);
  97. GLIB_AVAILABLE_IN_2_36
  98. gboolean g_task_get_return_on_cancel (GTask *task);
  99. GLIB_AVAILABLE_IN_2_36
  100. void g_task_attach_source (GTask *task,
  101. GSource *source,
  102. GSourceFunc callback);
  103. GLIB_AVAILABLE_IN_2_36
  104. void g_task_return_pointer (GTask *task,
  105. gpointer result,
  106. GDestroyNotify result_destroy);
  107. GLIB_AVAILABLE_IN_2_36
  108. void g_task_return_boolean (GTask *task,
  109. gboolean result);
  110. GLIB_AVAILABLE_IN_2_36
  111. void g_task_return_int (GTask *task,
  112. gssize result);
  113. GLIB_AVAILABLE_IN_2_36
  114. void g_task_return_error (GTask *task,
  115. GError *error);
  116. GLIB_AVAILABLE_IN_2_36
  117. void g_task_return_new_error (GTask *task,
  118. GQuark domain,
  119. gint code,
  120. const char *format,
  121. ...) G_GNUC_PRINTF (4, 5);
  122. GLIB_AVAILABLE_IN_2_36
  123. gboolean g_task_return_error_if_cancelled (GTask *task);
  124. GLIB_AVAILABLE_IN_2_36
  125. gpointer g_task_propagate_pointer (GTask *task,
  126. GError **error);
  127. GLIB_AVAILABLE_IN_2_36
  128. gboolean g_task_propagate_boolean (GTask *task,
  129. GError **error);
  130. GLIB_AVAILABLE_IN_2_36
  131. gssize g_task_propagate_int (GTask *task,
  132. GError **error);
  133. GLIB_AVAILABLE_IN_2_36
  134. gboolean g_task_had_error (GTask *task);
  135. G_END_DECLS
  136. #endif /* __G_TASK_H__ */