Does anyone know of a thread-pool like implementation for .NET that supports the following features:
- dependencies between tasks
- task priorities
- sub-tasks
Basically I'd like to throw a bunch of tasks at this pool, with some inter-dependencies (ie. make sure task A completes before task B is allowed to start).
Priorities would be used if two tasks have no dependencies on each other to determine which goes first.
Of course, I can throw all these objects into the pool, and let each object just wait for its dependencies to complete, but I assume (and please correct me if I'm wrong) that this will potentially start a lot of worker threads for objects that really have no place in the execution queue just yet since they'll block immediately.
Is there such an implementation?
Example:
Task#1 is submitted
Task#2 is submitted
Task#3 is submitted, depends on Task#1
Task#4 is submitted, depends on Task#1
Task#5 is submitted, depends on Task#1-4
This would have the following plan
Task#1 Task#2
| | |
| +--------+ |
| | | |
| v v |
| Task#3 Task#4 |
| | | |
v v v v
-----Task#5----------
This could, as an example, run Task#1 and Task#2 simultaneously, and as soon as Task#1 completed, Task#3 and Task#4 might run. When Task#3, Task#4 and Task#2 are all done, Task#5 is started.
Now, these could again launch sub-tasks that needs to complete before the task that launched them is considered "complete".
For instance, Task#4 might submit Task#6 and Task#7, which would have to complete before Task#4 is marked "done", but Task#4 might still exit, cleaning up the worker thread, it is just not considered "done" before sub-tasks it submitted also complete.
Is there such a system?
Note that this is all in-memory, I don't need anything to survive a program crash, machine reset, or anything, so thread-pool-like is good enough.