Repository navigation
parallel Task
The parallel task is the primary addition made by pNAnt. This task allows you to call multiple targets simultaneously. All child items of the task started simultaneously. The parallel task will complete only once all child items are completed.
The task has the following attributes (there are no required attributes):
-
name: Allows you to give a name to the task. This serves both to increase build script readability and is also used by pNAnt when logging to the console. -
description: Allows you to describe this task to improve buildscript readability. Unlikename, the value of this attribute is ignored by pNAnt. -
forceSequential: A boolean value that, when evaluated totrue, foreces thisparallaltask to execute each target in order, rather than in parallel, thereby disabling any parallalization. This is useful if you would like to run targets in parallel only under certain circumstances. The default value isfalse, obviously. -
cacophony: A boolean value that, when evaluated totrue, makes all children of thisparalleltask output their log messages immediately as they happen. See here for more information about cacophony logging. The use of this attribute is not recommended. The default value isfalse. -
if: Same as theifattrubute of other NAnt tasks. -
unless: Same as theunlessattrubute of other NAnt tasks. - __'failonerror
__: Same as thefailonerror` of other NAnt tasks.
The parallel task supports three nested element types which are used to specify the actions that should be performed in parallel:
The pcall element is the the most important element within the <parallel>' task. It specifies a target to perform in parallel. The pcall element has one required attrubute, target, which specifies the name of the target. In addition, the if and unless attributes are supported and behave as expected.
The sequence task specifies targets that are to be run in sequence, but the sequence as a whole can be run in parallel with other children on this <parallel>. See the examples section below and the sequence page for more information.
A parallel task can contain other nested parallel tasks. This serves no direct purpose other than to allow for logical groupings in the build script. All targets within a nested parallel are executed at the same time as the pcalls in the parent task.
A simple example that calls three targets in parallel. The parallel has a name and description, neither of which are required.
<parallel name="Simple Example" description="This is a simple example">
<pcall target="target_alpha"/>
<pcall target="${target_name}" if="${some_condition}" />
<pcall target="target_charlie" unless="${some_condition"/>
</parallel>
The following shows the use of the nested sequence task. In this example, TargetX will start at the same time as TargetA and TargetB. Once TargetX completes, TargetY will start. Once TargetY finishes. TargetZ will start.
<parallel>
<pcall target="targetA"/>
<sequence description="This will start at the same time as targetA and TargetB">
<pcall target="targetX"/>
<pcall target="targetY"/>
<pcall target="targetZ"/>
</sequence>
<pcall target="targetB"/>
</parallel>
Sequence tasks can themselves have parallel and sequence tasks within them. Here is a more complicated example. In this examples, all the "X" targets will start at the same time and all of the "Y" targets will start simultaneously once X3 finishes.
<parallel>
<pcall target="X1"/>
<sequence>
<parallel>
<pcall target="X2"/>
<pcall target="X3"/>
</parallel>
<parallel>
<pcall target="Y1"/>
<pcall target="Y2"/>
<sequence>
<pcall target="Y3"/>
<parallel>
<pcall target="Z1"/>
<pcall target="Z2"/>
</parallel>
</sequence>
</parallel>
</sequence>
</parallel>