GTask dependencies
@matthiasc
Submitted by Matthias Clasen Link to original bug (#747576)
Description
Wishlist item from Christian Hergert:
GTask Dependencies
One thing I miss from IrisTask[1] is the ability to chain tasks together. Both dependencies as well as result chaining. The dependencies I can live without right now, but what would be really nice is if we could propagate a result from a single task to additional tasks.
Use case:
I have a really expensive operation, such as generating a compilation unit for a file. I need to use that compilation unit for highlighting sources, generating a symbol list, auto-completion, and diagnostics. Clearly we don't want 4 concurrent operations to compile the same translation unit. We want the ability to hand the same result back to multiple of them (reference incremented of course).
Right now, I bend over backwards to store the task, a small lookup structure, and careful locking to ensure I don't walk over myself. If the operations require that the calling thread matches the gtask creator thread, then we don't need to manage locking external to the task (just internally in the task).
If the task has a result, but has not had its callback executed (as could happen since this new caller would be executing on the callback thread), the result should still be propagated.
Errors should also be propagated.
This might be useful API:
void g_task_chain_result (GTask *self, GTask *other);
In the future, I want some of the other stuff IrisTask did. You can create asynchronous control flow up front, and then just let it run.
[1] https://github.com/chergert/iris/blob/master/iris/iris-task.h#L193 [2] https://github.com/chergert/iris/blob/master/iris/iris-task.h#L249