Skip to content

Nesting

Eric McGary edited this page Jan 6, 2013 · 2 revisions

As stated above the tasks within the library implement the composite design pattern, this simply means that all groups of tasks are themselves tasks. Tasks have the ability to have sub tasks nested within them, turning them into task groups. By default nested tasks run sequentially, unless otherwise specified. Currently the two types of task groups available are `sequence` and `parallel` (implementation examples above).

Sequential tasks run sub tasks one after another until all sub tasks complete. When all nested sub tasks are complete the complete state is passed to the task groups change method for handling.

Parallel tasks are task groups who's nested subtasks are executed side by side, executing whenever they can. Just like the sequential task group, when all sub tasks have completed the groups change method will be notified.

There is no limit to the depth of which you nest tasks, which is where the power of the library starts to become apparent. You can view a more complex example of this in the complex example within the examples directory.

You can read more about decorating tasks in the Decorating Tasks section of the wiki, but there is one important note here as it relates to nesting. You can apply decorations to nested subtasks just as you would to a simple task. For instance if you were to apply a for decoration to nested sub task within a sequence group task, the group would wait for the sub task to run as many times as it needed to before moving on to the next task in the queue.

Clone this wiki locally