### Method

# Gio Task return_pointer

since: 2.36

#### Declaration

    void
    g_task_return_pointer (
      GTask* task,
      gpointer result,
      GDestroyNotify result_destroy
    )

#### Description

Sets `task`‘s result to `result` and completes the task. If `result` is not `NULL`, then `result_destroy` will be used to free `result` if the caller does not take ownership of it with g_task_propagate_pointer().

“Completes the task” means that for an ordinary asynchronous task it will either invoke the task’s callback, or else queue that callback to be invoked in the proper `GMainContext`, or in the next iteration of the current `GMainContext`. For a task run via `g_task_run_in_thread()` or g_task_run_in_thread_sync(), calling this method will save `result` to be returned to the caller later, but the task will not actually be completed until the `GTaskThreadFunc` exits.

Note that since the task may be completed before returning from g_task_return_pointer(), you cannot assume that `result` is still valid after calling this, unless you are still holding another reference on it.

Available since: 2.36

#### Parameters

`result`

  Type: `gpointer`

  The pointer result of a task function.

  The argument can be `NULL`.
  The instance takes ownership of the data, and is responsible for freeing it.

`result_destroy`

  Type: `GDestroyNotify`

  A `GDestroyNotify` function.

  The argument can be `NULL`.