<parallel>
This container takes each of its child elements and executes it in a separate thread. The join attribute creates a barrier.
Examples
<parallel idPrefix="1P" join="true"> <while taskName="1WA" condition="$E{true}"> <declare name="t" double="${t}"/> <declare name="p" double="${p}"/> <if condition="$E{ ! ( ( ${t} < 0.5 ) && ( ${t} > -1 ) ) }"> <call procedure="computeTP" ARG_x0="${t}" ARG_y0="${p}" RET_t="t" RET_p="p"/> <else> <declare name="tfinal0" double="${t}" global="true"/> </else> </if> <if> <not><is-null object="${tfinal0}"/></not> <break/> </if> </while> <while taskName="1WB" condition="$E{true}"> <declare name="t" double="${t}"/> <declare name="p" double="${p}"/> <if condition="$E{ ! ( ( ${t} < -1.75 ) && ( ${t} > -1.8 ) ) }"> <call procedure="computeTP" ARG_x0="${t}" ARG_y0="${p}" RET_t="t" RET_p="p"/> <else> <declare name="tfinal1" double="${t}" global="true"/> </else> </if> <if> <not><is-null object="${tfinal0}"/></not> <break/> </if> </while> </parallel>
Here, the two while-loops are run in separate threads, but the container task does not return until both threads exit (join="true").
The parallel
container generates a number of identifiers automatically, placing them in the environment:
- The thread object itself is mapped to the generated id, which is the idPrefix + '-' + the number of the child element; hence the first while loop thread would be '1P-0', the second, '1P-1'. This variable is placed on the global frame, for joining purposes.
- The generated id itself is placed on the local frame as pTaskId.
- The number of the child is also placed on the local frame as a Long value, pTaskNumber.