Gio.Task.prototype.return_pointer

function return_pointer(result: void, result_destroy: GLib.DestroyNotify): void {
    // Gjs wrapper for g_task_return_pointer()
}
  

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 Gio.Task.prototype.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 GLib.MainContext, or in the next iteration of the current GLib.MainContext. For a task run via Gio.Task.run_in_thread or Gio.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 Gio.TaskThreadFunc exits.

Note that since the task may be completed before returning from Gio.Task.prototype.return_pointer, you cannot assume that result is still valid after calling this, unless you are still holding another reference on it.

Since 2.36

result

the pointer result of a task function

result_destroy

a GLib.DestroyNotify function.