gcancellable.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /* GIO - GLib Input, Output and Streaming Library
  2. *
  3. * Copyright (C) 2006-2007 Red Hat, Inc.
  4. *
  5. * SPDX-License-Identifier: LGPL-2.1-or-later
  6. *
  7. * This library is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * This library is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General
  18. * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
  19. *
  20. * Author: Alexander Larsson <alexl@redhat.com>
  21. */
  22. #ifndef __G_CANCELLABLE_H__
  23. #define __G_CANCELLABLE_H__
  24. #if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
  25. #error "Only <gio/gio.h> can be included directly."
  26. #endif
  27. #include <gio/giotypes.h>
  28. G_BEGIN_DECLS
  29. #define G_TYPE_CANCELLABLE (g_cancellable_get_type ())
  30. #define G_CANCELLABLE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_CANCELLABLE, GCancellable))
  31. #define G_CANCELLABLE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_CANCELLABLE, GCancellableClass))
  32. #define G_IS_CANCELLABLE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_CANCELLABLE))
  33. #define G_IS_CANCELLABLE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_CANCELLABLE))
  34. #define G_CANCELLABLE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_CANCELLABLE, GCancellableClass))
  35. typedef struct _GCancellableClass GCancellableClass;
  36. typedef struct _GCancellablePrivate GCancellablePrivate;
  37. struct _GCancellable
  38. {
  39. GObject parent_instance;
  40. /*< private >*/
  41. GCancellablePrivate *priv;
  42. };
  43. struct _GCancellableClass
  44. {
  45. GObjectClass parent_class;
  46. void (* cancelled) (GCancellable *cancellable);
  47. /*< private >*/
  48. /* Padding for future expansion */
  49. void (*_g_reserved1) (void);
  50. void (*_g_reserved2) (void);
  51. void (*_g_reserved3) (void);
  52. void (*_g_reserved4) (void);
  53. void (*_g_reserved5) (void);
  54. };
  55. GIO_AVAILABLE_IN_ALL
  56. GType g_cancellable_get_type (void) G_GNUC_CONST;
  57. GIO_AVAILABLE_IN_ALL
  58. GCancellable *g_cancellable_new (void);
  59. /* These are only safe to call inside a cancellable op */
  60. GIO_AVAILABLE_IN_ALL
  61. gboolean g_cancellable_is_cancelled (GCancellable *cancellable);
  62. GIO_AVAILABLE_IN_ALL
  63. gboolean g_cancellable_set_error_if_cancelled (GCancellable *cancellable,
  64. GError **error);
  65. GIO_AVAILABLE_IN_ALL
  66. int g_cancellable_get_fd (GCancellable *cancellable);
  67. GIO_AVAILABLE_IN_ALL
  68. gboolean g_cancellable_make_pollfd (GCancellable *cancellable,
  69. GPollFD *pollfd);
  70. GIO_AVAILABLE_IN_ALL
  71. void g_cancellable_release_fd (GCancellable *cancellable);
  72. GIO_AVAILABLE_IN_ALL
  73. GSource * g_cancellable_source_new (GCancellable *cancellable);
  74. GIO_AVAILABLE_IN_ALL
  75. GCancellable *g_cancellable_get_current (void);
  76. GIO_AVAILABLE_IN_ALL
  77. void g_cancellable_push_current (GCancellable *cancellable);
  78. GIO_AVAILABLE_IN_ALL
  79. void g_cancellable_pop_current (GCancellable *cancellable);
  80. GIO_AVAILABLE_IN_ALL
  81. void g_cancellable_reset (GCancellable *cancellable);
  82. GIO_AVAILABLE_IN_ALL
  83. gulong g_cancellable_connect (GCancellable *cancellable,
  84. GCallback callback,
  85. gpointer data,
  86. GDestroyNotify data_destroy_func);
  87. GIO_AVAILABLE_IN_ALL
  88. void g_cancellable_disconnect (GCancellable *cancellable,
  89. gulong handler_id);
  90. /* This is safe to call from another thread */
  91. GIO_AVAILABLE_IN_ALL
  92. void g_cancellable_cancel (GCancellable *cancellable);
  93. G_END_DECLS
  94. #endif /* __G_CANCELLABLE_H__ */