since: 1.0

Declaration [src]

valent_object_attach_cancellable (
  ValentObject* object,
  GCancellable* cancellable

Description [src]

Attach the object’s cancellable another cancellable.

This connects ValentObject:cancellable to cancellables GCancellable::cancelled so that if cancellable is cancelled, objects cancellable will be cancelled. For convenience, this method returns a reference of ValentObject:cancellable.

Typically the returned GCancellable is passed to a GAsyncInitable implementation to ensure initialization is cancelled if cancellable is triggered or object is destroyed.

static void
foo_async_initable_init_async (GAsyncInitable      *initable,
                               int                  io_priority,
                               GCancellable        *cancellable,
                               GAsyncReadyCallback  callback,
                               gpointer             user_data)
  g_autoptr (GTask) task = NULL;
  g_autoptr (GCancellable) destroy = NULL;

  g_assert (VALENT_IS_OBJECT (initable));

  destroy = valent_object_attach_cancellable (VALENT_OBJECT (initable),

  task = g_task_new (initable, destroy, callback, user_data);
  g_task_set_priority (task, io_priority);
  g_task_run_in_thread (task, foo_async_initable_init_task);

Available since: 1.0



Type: GCancellable

A GCancellable.

The argument can be NULL.
The data is owned by the caller of the function.

Return value

Type: GCancellable

objects GCancellable.

The caller of the method takes ownership of the data, and is responsible for freeing it.