The Parallel interface holds methods that ParallelEnhancer adds to classes or instances when they get enhanced.
Constructor and description |
---|
Parallel
() |
Type | Name and description |
---|---|
boolean |
anyParallel(groovy.lang.Closure cl) Performs the any() operation using an asynchronous variant of the supplied closure to evaluate each collection's/object's element. |
static void |
asConcurrent(java.lang.Object collection, groovy.lang.Closure code) Makes the collection concurrent for the passed-in block of code. |
java.lang.Object |
collectManyParallel(groovy.lang.Closure cl) Iterates over a collection/object with the collectMany() method using an asynchronous variant of the supplied closure to evaluate each collection's element. |
java.lang.Object |
collectParallel(groovy.lang.Closure cl) Iterates over a collection/object with the collect() method using an asynchronous variant of the supplied closure to evaluate each collection's element. |
java.lang.Object |
countParallel(java.lang.Object filter) Performs the count() operation using an asynchronous variant of the supplied closure to evaluate each collection's/object's element. |
java.lang.Object |
eachParallel(groovy.lang.Closure cl) Iterates over a collection/object with the each() method using an asynchronous variant of the supplied closure to evaluate each collection's element. |
java.lang.Object |
eachWithIndexParallel(groovy.lang.Closure cl) Iterates over a collection/object with the eachWithIndex() method using an asynchronous variant of the supplied closure to evaluate each collection's element. |
private static java.lang.Object |
enhance(java.lang.Object collection) Enhances to resulting collection so that parallel methods can be chained. |
boolean |
everyParallel(groovy.lang.Closure cl) Performs the all() operation using an asynchronous variant of the supplied closure to evaluate each collection's/object's element. |
java.lang.Object |
findAllParallel(groovy.lang.Closure cl) Performs the findAll() operation using an asynchronous variant of the supplied closure to evaluate each collection's/object's element. |
java.lang.Object |
findAnyParallel(groovy.lang.Closure cl) Performs the find() operation using an asynchronous variant of the supplied closure to evaluate each collection's/object's element. |
java.lang.Object |
findParallel(groovy.lang.Closure cl) Performs the find() operation using an asynchronous variant of the supplied closure to evaluate each collection's/object's element. |
java.lang.Object |
foldParallel(groovy.lang.Closure cl) Creates a Parallel Array out of the supplied collection/object and invokes its reduce() method using the supplied closure as the reduction operation. |
java.lang.Object |
foldParallel(java.lang.Object seed, groovy.lang.Closure cl) Creates a Parallel Array out of the supplied collection/object and invokes its reduce() method using the supplied closure as the reduction operation. |
PAWrapper |
getParallel() Creates a PAWrapper around a ParallelArray wrapping te elements of the original collection. |
private java.lang.Object |
getRealSelf() Retrieves the mixed it parent and potentially casts it dynamically to a Map. |
java.lang.Object |
grepParallel(java.lang.Object filter) Performs the grep() operation using an asynchronous variant of the supplied closure to evaluate each collection's/object's element. |
java.lang.Object |
groupByParallel(groovy.lang.Closure cl) Performs the groupBy() operation using an asynchronous variant of the supplied closure to evaluate each collection's/object's element. |
java.lang.Object |
injectParallel(groovy.lang.Closure cl) Creates a Parallel Array out of the supplied collection/object and invokes its reduce() method using the supplied closure as the reduction operation. |
java.lang.Object |
injectParallel(java.lang.Object seed, groovy.lang.Closure cl) Creates a Parallel Array out of the supplied collection/object and invokes its reduce() method using the supplied closure as the reduction operation. |
boolean |
isConcurrent() Indicates, whether the iterative methods like each() or collect() have been made parallel. |
static java.lang.Object |
makeConcurrent(java.lang.Object collection) Overrides the iterative methods like each(), collect() and such, so that they call their parallel variants from the GParsPoolUtil class like eachParallel(), collectParallel() and such. |
static java.lang.Object |
makeSequential(java.lang.Object collection) Gives the iterative methods like each() or find() the original sequential semantics. |
java.lang.Object |
maxParallel(groovy.lang.Closure cl) Creates a Parallel Array out of the supplied collection/object and invokes its max() method using the supplied closure as the comparator. |
java.lang.Object |
maxParallel() Creates a Parallel Array out of the supplied collection/object and invokes its max() method using the default comparator. |
java.lang.Object |
minParallel(groovy.lang.Closure cl) Creates a Parallel Array out of the supplied collection/object and invokes its min() method using the supplied closure as the comparator. |
java.lang.Object |
minParallel() Creates a Parallel Array out of the supplied collection/object and invokes its min() method using the default comparator. |
java.lang.Object |
splitParallel(groovy.lang.Closure cl) Performs the split() operation using an asynchronous variant of the supplied closure to evaluate each collection's/object's element. |
java.lang.Object |
sumParallel() Creates a Parallel Array out of the supplied collection/object and summarizes its elements using the foldParallel() method with the + operator and the reduction operation. |
Methods inherited from class | Name |
---|---|
class java.lang.Object |
java.lang.Object#wait(), java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
Performs the any() operation using an asynchronous variant of the supplied closure to evaluate each collection's/object's element. The anyParallel() method is lazy and once a positive answer has been given by at least one element, it avoids running the supplied closure on subsequent elements. After this method returns, all the closures have been finished and the caller can safely use the result. It's important to protect any shared resources used by the supplied closure from race conditions caused by multi-threaded access. If any of the collection's elements causes the closure to throw an exception, the exception is re-thrown.
Makes the collection concurrent for the passed-in block of code. The iterative methods like each or collect are given concurrent semantics inside the passed-in closure. Once the closure finishes, the original sequential semantics of the methods is restored.
collection
- The collection to enhancecode
- The closure to run with the collection enhanced.Iterates over a collection/object with the collectMany() method using an asynchronous variant of the supplied closure to evaluate each collection's element. After this method returns, all the closures have been finished and the caller can safely use the result. It's important to protect any shared resources used by the supplied closure from race conditions caused by multi-threaded access. If any of the collection's elements causes the closure to throw an exception, the exception is re-thrown.
Iterates over a collection/object with the collect() method using an asynchronous variant of the supplied closure to evaluate each collection's element. After this method returns, all the closures have been finished and the caller can safely use the result. It's important to protect any shared resources used by the supplied closure from race conditions caused by multi-threaded access. If any of the collection's elements causes the closure to throw an exception, the exception is re-thrown.
Performs the count() operation using an asynchronous variant of the supplied closure to evaluate each collection's/object's element. After this method returns, all the closures have been finished and the caller can safely use the result. It's important to protect any shared resources used by the supplied closure from race conditions caused by multi-threaded access. If any of the collection's elements causes the closure to throw an exception, the exception is re-thrown.
Iterates over a collection/object with the each() method using an asynchronous variant of the supplied closure to evaluate each collection's element. After this method returns, all the closures have been finished and all the potential shared resources have been updated by the threads. It's important to protect any shared resources used by the supplied closure from race conditions caused by multi-threaded access. If any of the collection's elements causes the closure to throw an exception, the exception is re-thrown.
Iterates over a collection/object with the eachWithIndex() method using an asynchronous variant of the supplied closure to evaluate each collection's element. After this method returns, all the closures have been finished and all the potential shared resources have been updated by the threads. It's important to protect any shared resources used by the supplied closure from race conditions caused by multi-threaded access. If any of the collection's elements causes the closure to throw an exception, the exception is re-thrown.
Enhances to resulting collection so that parallel methods can be chained.
Performs the all() operation using an asynchronous variant of the supplied closure to evaluate each collection's/object's element. After this method returns, all the closures have been finished and the caller can safely use the result. It's important to protect any shared resources used by the supplied closure from race conditions caused by multi-threaded access. If any of the collection's elements causes the closure to throw an exception, the exception is re-thrown.
Performs the findAll() operation using an asynchronous variant of the supplied closure to evaluate each collection's/object's element. After this method returns, all the closures have been finished and the caller can safely use the result. It's important to protect any shared resources used by the supplied closure from race conditions caused by multi-threaded access. If any of the collection's elements causes the closure to throw an exception, the exception is re-thrown.
Performs the find() operation using an asynchronous variant of the supplied closure to evaluate each collection's/object's element. Unlike with the find method, findAnyParallel() does not guarantee that the a matching element with the lowest index is returned. The findAnyParallel() method evaluates elements lazily and stops processing further elements of the collection once a match has been found. After this method returns, all the closures have been finished and the caller can safely use the result. It's important to protect any shared resources used by the supplied closure from race conditions caused by multi-threaded access. If any of the collection's elements causes the closure to throw an exception, the exception is re-thrown.
Performs the find() operation using an asynchronous variant of the supplied closure to evaluate each collection's/object's element. After this method returns, all the closures have been finished and the caller can safely use the result. It's important to protect any shared resources used by the supplied closure from race conditions caused by multi-threaded access. If any of the collection's elements causes the closure to throw an exception, the exception is re-thrown.
Creates a Parallel Array out of the supplied collection/object and invokes its reduce() method using the supplied closure as the reduction operation. The closure will be effectively invoked concurrently on the elements of the collection. After all the elements have been processed, the method returns the reduction result of the elements in the collection. It's important to protect any shared resources used by the supplied closure from race conditions caused by multi-threaded access. Alternatively a DSL can be used to simplify the code. All collections/objects within the withPool block have a new min(Closure cl) method, which delegates to the GParsPoolUtil class.
Creates a Parallel Array out of the supplied collection/object and invokes its reduce() method using the supplied closure as the reduction operation. The closure will be effectively invoked concurrently on the elements of the collection. After all the elements have been processed, the method returns the reduction result of the elements in the collection. It's important to protect any shared resources used by the supplied closure from race conditions caused by multi-threaded access. Alternatively a DSL can be used to simplify the code. All collections/objects within the withPool block have a new min(Closure cl) method, which delegates to the GParsPoolUtil class.
seed
- A seed value to initialize the operationCreates a PAWrapper around a ParallelArray wrapping te elements of the original collection. This allows further parallel processing operations on the collection to chain and so effectively leverage the underlying ParallelArray implementation.
Retrieves the mixed it parent and potentially casts it dynamically to a Map. The cast to Map is needed since Maps additionally accept a two-argument closures in iterative methods.
Performs the grep() operation using an asynchronous variant of the supplied closure to evaluate each collection's/object's element. After this method returns, all the closures have been finished and the caller can safely use the result. It's important to protect any shared resources used by the supplied closure from race conditions caused by multi-threaded access. If any of the collection's elements causes the closure to throw an exception, the exception is re-thrown.
Performs the groupBy() operation using an asynchronous variant of the supplied closure to evaluate each collection's/object's element. After this method returns, all the closures have been finished and the caller can safely use the result. It's important to protect any shared resources used by the supplied closure from race conditions caused by multi-threaded access. If any of the collection's elements causes the closure to throw an exception, the exception is re-thrown.
Creates a Parallel Array out of the supplied collection/object and invokes its reduce() method using the supplied closure as the reduction operation. The closure will be effectively invoked concurrently on the elements of the collection. After all the elements have been processed, the method returns the reduction result of the elements in the collection. It's important to protect any shared resources used by the supplied closure from race conditions caused by multi-threaded access. Alternatively a DSL can be used to simplify the code. All collections/objects within the withPool block have a new min(Closure cl) method, which delegates to the GParsPoolUtil class.
Creates a Parallel Array out of the supplied collection/object and invokes its reduce() method using the supplied closure as the reduction operation. The closure will be effectively invoked concurrently on the elements of the collection. After all the elements have been processed, the method returns the reduction result of the elements in the collection. It's important to protect any shared resources used by the supplied closure from race conditions caused by multi-threaded access. Alternatively a DSL can be used to simplify the code. All collections/objects within the withPool block have a new min(Closure cl) method, which delegates to the GParsPoolUtil class.
seed
- A seed value to initialize the operationIndicates, whether the iterative methods like each() or collect() have been made parallel.
Overrides the iterative methods like each(), collect() and such, so that they call their parallel variants from the GParsPoolUtil class like eachParallel(), collectParallel() and such. The first time it is invoked on a collection the method creates a TransparentParallel class instance and mixes it in the object it is invoked on. After mixing-in, the isConcurrent() method will return true. Delegates to GParsPoolUtil.makeConcurrent().
collection
- The object to make transparentGives the iterative methods like each() or find() the original sequential semantics.
collection
- The collection to apply the change toCreates a Parallel Array out of the supplied collection/object and invokes its max() method using the supplied closure as the comparator. The closure will be effectively invoked concurrently on the elements of the collection. After all the elements have been processed, the method returns the maximum of the elements in the collection. It's important to protect any shared resources used by the supplied closure from race conditions caused by multi-threaded access. Alternatively a DSL can be used to simplify the code. All collections/objects within the withPool block have a new min(Closure cl) method, which delegates to the GParsPoolUtil class. If the supplied closure takes two arguments it is used directly as a comparator. If the supplied closure takes one argument, the values returned by the supplied closure for individual elements are used for comparison by the implicit comparator.
cl
- A one or two-argument closureCreates a Parallel Array out of the supplied collection/object and invokes its max() method using the default comparator. The closure will be effectively invoked concurrently on the elements of the collection. After all the elements have been processed, the method returns the maximum of the elements in the collection. Alternatively a DSL can be used to simplify the code. All collections/objects within the withPool block have a new min(Closure cl) method, which delegates to the GParsPoolUtil class.
Creates a Parallel Array out of the supplied collection/object and invokes its min() method using the supplied closure as the comparator. The closure will be effectively invoked concurrently on the elements of the collection. After all the elements have been processed, the method returns the minimum of the elements in the collection. It's important to protect any shared resources used by the supplied closure from race conditions caused by multi-threaded access. Alternatively a DSL can be used to simplify the code. All collections/objects within the withPool block have a new min(Closure cl) method, which delegates to the GParsPoolUtil class. If the supplied closure takes two arguments it is used directly as a comparator. If the supplied closure takes one argument, the values returned by the supplied closure for individual elements are used for comparison by the implicit comparator.
cl
- A one or two-argument closureCreates a Parallel Array out of the supplied collection/object and invokes its min() method using the default comparator. The closure will be effectively invoked concurrently on the elements of the collection. After all the elements have been processed, the method returns the minimum of the elements in the collection. Alternatively a DSL can be used to simplify the code. All collections/objects within the withPool block have a new min(Closure cl) method, which delegates to the GParsPoolUtil class.
Performs the split() operation using an asynchronous variant of the supplied closure to evaluate each collection's/object's element. After this method returns, all the closures have been finished and the caller can safely use the result. It's important to protect any shared resources used by the supplied closure from race conditions caused by multi-threaded access. If any of the collection's elements causes the closure to throw an exception, the exception is re-thrown.
Creates a Parallel Array out of the supplied collection/object and summarizes its elements using the foldParallel() method with the + operator and the reduction operation. The closure will be effectively invoked concurrently on the elements of the collection. After all the elements have been processed, the method returns the sum of the elements in the collection. Alternatively a DSL can be used to simplify the code. All collections/objects within the withPool block have a new min(Closure cl) method, which delegates to the GParsPoolUtil class.
Copyright © 2008–2014 Václav Pech. All Rights Reserved.