Cernunnos Manual


<concurrent>

Description:

Executes the subtasks concurrently using the thread pool from the request under the default attribute name 'ConcurrentAttributes.EXECUTOR_SERVICE'.

Use this task within a <thread-pool> task.

Reagents:

Name XPath Description Reagent Type Expected Type Required
EXECUTOR_SERVICE @executor-service Optional instance of ExecutorService. The default is a request attribute under the name 'ConcurrentAttributes.EXECUTOR_SERVICE'. PHRASE java.util.concurrent.ExecutorService No
FAIL_FAST @fail-fast If true an exception from a sub task will cause the parent thread pool to be shutdown immediately. Thedefault is true. PHRASE java.lang.String No
SUBTASKS * The set of tasks that are children of this task. NODE_LIST java.util.List No

Examples:

Creates an array of three URLs in JavaScript, then computes a checksum value ten times for one of the URLs in the array (distributed evenly) using a pool of five threads, writing the current count and checksum value to the console each time:

 
       
        <js> 
          <script>var urls = ['http://www.google.com/', 'http://www.amazon.com/', 'http://www.yahoo.com/']; ScriptAttributes.RESPONSE.setAttribute('urls', urls);</script>  
          <subtasks> 
            <thread-pool threads="5"> 
              <for-each attribute-name="num" items="${groovy([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])}"> 
                <concurrent> 
                  <echo-ln>${num}=${checksum(${js(urls[num % 3])})}</echo-ln> 
                </concurrent> 
              </for-each> 
            </thread-pool> 
          </subtasks> 
        </js>