summaryrefslogtreecommitdiff
path: root/gio/src/cancellable.hg
blob: fd6bcd0f816bcabd47bf8343f5564906231e4041 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 2 -*-

/* Copyright (C) 2007 The gtkmm Development Team
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the Free
 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

//TODO: Avoid this:
#include <gio/gio.h>

#include <glibmm/object.h>

_DEFS(giomm,gio)
_PINCLUDE(glibmm/private/object_p.h)

namespace Gio
{

/** Allows actions to be cancelled.
 * Cancellable is a thread-safe operation cancellation stack used throughout GIO to allow for cancellation of synchronous and asynchronous operations.
 */
class Cancellable : public Glib::Object
{
  _CLASS_GOBJECT(Cancellable, GCancellable, G_CANCELLABLE, Glib::Object, GObject)

protected:
  _CTOR_DEFAULT

public:
  _WRAP_CREATE()

  _WRAP_METHOD(bool is_cancelled() const, g_cancellable_is_cancelled)

  _IGNORE(g_cancellable_set_error_if_cancelled)

  //May return -1 if fds not supported, or on errors .
  _WRAP_METHOD(int get_fd() const, g_cancellable_get_fd)

  //This is safe to call from another thread.
  _WRAP_METHOD(void cancel(), g_cancellable_cancel)

  _IGNORE(g_cancellable_get_current)

  /** Gets the top cancellable from the stack.
   * @result a Cancellable from the top of the stack, or an invalid RefPtr if the stack is empty.
   */
  static Glib::RefPtr<Cancellable> get_current();

  _WRAP_METHOD(void push_current(),
               g_cancellable_push_current)
  _WRAP_METHOD(void pop_current(),
               g_cancellable_pop_current)
  _WRAP_METHOD(void reset(), g_cancellable_reset)
};

} // namespace Gio