Skip to content

gtask: Add complete-in-idle flag

Benjamin Berg requested to merge bberg/glib:benzea/complete-in-idle into master

To be fair, I am not sure if this really is a great idea. But it seemed useful to me earlier today and it was easy enough to write.

When possible GTask tries to execute the user callback immediately. While this is usually desirable, it does mean that API users need to have taken care of all cleanups, etc. already before calling g_task_return_pointer. In some cases it may simplify the logic though if one can rely on the task to not be completed immediately.

Using this flag creates guarantees for API users that are similar to the ones of g_task_run_in_thread where the task will only be completed after the thread function has returned. It has no effect for threaded tasks.

Merge request reports