Sets or clears
task‘s return-on-cancel flag. This is only
meaningful for tasks run via
g_task_run_in_thread() or g_task_run_in_thread_sync().
TRUE, then cancelling
GCancellable will immediately cause it to return, as though the
GTaskThreadFunc had called
g_task_return_error_if_cancelled() and then returned.
This allows you to create a cancellable wrapper around an
uninterruptible function. The
GTaskThreadFunc just needs to be
careful that it does not modify any externally-visible state after
it has been cancelled. To do that, the thread should call
g_task_set_return_on_cancel() again to (atomically) set
FALSE before making externally-visible changes;
if the task gets cancelled before the return-on-cancel flag could
g_task_set_return_on_cancel() will indicate this by
You can disable and re-enable this flag multiple times if you wish.
If the task’s
GCancellable is cancelled while return-on-cancel is
FALSE, then calling
g_task_set_return_on_cancel() to set it
again will cause the task to be cancelled at that point.
If the task’s
GCancellable is already cancelled before you call
g_task_run_in_thread()/g_task_run_in_thread_sync(), then the
GTaskThreadFunc will still be run (for consistency), but the task
will also be completed right away.
Available since: 2.36
Whether the task returns automatically when it is cancelled.