<parallel-for-each>

This container sets up parallel blocks of tasks in order to process a list of values; in other words, it unrolls a <for-each> loop and parallelizes the unrolled parts.

The attributes for this container are: idPrefix, parallelism (= "copies" in the parallel-block container), and var (as in <for-each>).

Like <for-each>, you can add a list from the environment or specify it as the first child element.

Examples

<ogrescript>
  <parallel-for-each var="statement" parallelism="10" idPrefix="printer">
       <list>
          <value>Print Statement 0</value>
          <value>Print Statement 1</value>
          <value>Print Statement 2</value>
          <value>Print Statement 3</value>
          <value>Print Statement 4</value>
          <value>Print Statement 5</value>
          <value>Print Statement 6</value>
          <value>Print Statement 7</value>
          <value>Print Statement 8</value>
          <value>Print Statement 9</value>
          <value>Print Statement 10</value>
          <value>Print Statement 11</value>
          <value>Print Statement 12</value>
          <value>Print Statement 13</value>
          <value>Print Statement 14</value>
          <value>Print Statement 15</value>
          <value>Print Statement 16</value>
       </list>
       <echo message="echoing for the first time: ${statement}" stdout="true"/>
       <sleep seconds="1"/>
       <echo message="echoing for the second time: ${statement}" stdout="true"/>
  </parallel-for-each>
</ogrescript>

Note that this container joins on its unrolled blocks. Like parallel-block, it makes available the three <parallel> identifiers.

  • No labels