Open j-woz opened 4 years ago
Adding some background about task granularity: To encompass a set of tasks with, e.g., a bracket, that would tell Swift that these tasks should all be executed in one go, i.e., that they wouldn’t be individually placed in the queue and get executed when their turn in the queue comes.
One use case where this would be helpful is for post-run cleanup tasks, for example, when you want to make sure that all the cleanup has occurred before other tasks that might create more files (and thereby hit some file size or number threshold) are run.
We realized in our 10/8/21 discussion that this task bundling can be implemented using priorities.
E.g., in the case of a sim task (S) and a cleanup task ( C), if we give S priority 1 (p1) and C priority 2 (p2), with p2 being a higher priority than p1, and have 2N combined S and C tasks:
1: [S p1, C p2]
...
N: [S p1, C p2]
N+1: [S p1, C p2]
...
2N: [S p1, C p2]
The first N S tasks will run first, with the next N S tasks in the task queue. As one of the first N S tasks completes, just before it does, it will release a C task into the queue, such that when it does complete and frees the worker, the C task will be the next to be run, rather than the N+1 - 2N S tasks. This way cleanup tasks that can run will run before any subsequent S tasks.
Is this enough to close this issue @j-woz, or do you think it warrants something beyond this?
Some way to couple tasks in the queue. Could be solved with launch_multi(), but other features may be needed.
CC @jozik @ncollier