org.codehaus.gpars

groovyx.gpars
[Java] Class GParsPoolUtil

java.lang.Object
  groovyx.gpars.GParsPoolUtil

public class GParsPoolUtil

This class forms the core of the DSL initialized by GParsPool. The static methods of GParsPoolUtil get attached to their first arguments (the Groovy Category mechanism) and can be then invoked as if they were part of the argument classes.

Authors:
Vaclav Pech
Robert Fischer Date: Mar 10, 2010
See Also:
GParsPool


Field Summary
private static GeneralTimer timer

 
Constructor Summary
GParsPoolUtil()

 
Method Summary
static boolean anyParallel(java.util.Collection collection, groovy.lang.Closure cl)

static boolean anyParallel(java.lang.Object collection, groovy.lang.Closure cl)

static boolean anyParallel(java.util.Map collection, groovy.lang.Closure cl)

static void asConcurrent(java.lang.Object collection, groovy.lang.Closure code)

Indicates whether the iterative methods like each() or collect() work have been altered to work concurrently.

static groovy.lang.Closure async(groovy.lang.Closure cl)

Creates an asynchronous and composable variant of the supplied closure, which, when invoked returns a DataflowVariable for the potential return value

static groovy.lang.Closure asyncFun(groovy.lang.Closure original)

Creates an asynchronous and composable variant of the supplied closure, which, when invoked returns a DataflowVariable for the potential return value

static groovy.lang.Closure asyncFun(groovy.lang.Closure original, boolean blocking)

Creates an asynchronous and composable variant of the supplied closure, which, when invoked returns a DataflowVariable for the potential return value

static groovy.lang.Closure asyncFun(groovy.lang.Closure original, FJPool pool)

static groovy.lang.Closure asyncFun(groovy.lang.Closure original, FJPool pool, boolean blocking)

static java.util.concurrent.Future callAsync(groovy.lang.Closure cl, java.lang.Object... args)

static java.util.concurrent.Future callParallel(groovy.lang.Closure task)

Calls a closure in a separate thread supplying the given arguments, returning a future for the potential return value.

static java.util.concurrent.Future callTimeoutAsync(groovy.lang.Closure cl, long timeout, java.lang.Object... args)

static java.util.concurrent.Future callTimeoutAsync(groovy.lang.Closure cl, groovy.time.Duration timeout, java.lang.Object... args)

Submits the task for asynchronous processing returning the Future received from the executor service.

static java.util.List collectManyParallel(java.util.Collection collection, groovy.lang.Closure projection)

static java.util.List collectManyParallel(java.lang.Object collection, groovy.lang.Closure projection)

static java.util.List collectManyParallel(java.util.Map collection, groovy.lang.Closure projection)

static java.util.Collection collectParallel(java.util.Collection collection, groovy.lang.Closure cl)

static java.util.Collection collectParallel(java.lang.Object collection, groovy.lang.Closure cl)

static java.util.Collection collectParallel(java.util.Map collection, groovy.lang.Closure cl)

static int countParallel(java.util.Collection collection, java.lang.Object filter)

static int countParallel(java.lang.Object collection, java.lang.Object filter)

static int countParallel(java.util.Collection collection, groovy.lang.Closure filter)

static int countParallel(java.lang.Object collection, groovy.lang.Closure filter)

private static ParallelArray createPA(java.util.Map collection, ForkJoinPool pool)

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.util.Collection eachParallel(java.util.Collection collection, groovy.lang.Closure cl)

static java.lang.Object eachParallel(java.lang.Object collection, groovy.lang.Closure cl)

static java.util.Map eachParallel(java.util.Map collection, groovy.lang.Closure cl)

static java.util.Collection eachWithIndexParallel(java.util.Collection collection, groovy.lang.Closure cl)

static java.lang.Object eachWithIndexParallel(java.lang.Object collection, groovy.lang.Closure cl)

Does parallel eachWithIndex on maps

static java.util.Map eachWithIndexParallel(java.util.Map collection, groovy.lang.Closure cl)

static boolean everyParallel(java.util.Collection collection, groovy.lang.Closure cl)

static boolean everyParallel(java.lang.Object collection, groovy.lang.Closure cl)

static boolean everyParallel(java.util.Map collection, groovy.lang.Closure cl)

static java.util.Collection findAllParallel(java.util.Collection collection, groovy.lang.Closure cl)

static java.util.Collection findAllParallel(java.lang.Object collection, groovy.lang.Closure cl)

static java.util.Map findAllParallel(java.util.Map collection, groovy.lang.Closure cl)

static java.lang.Object findAnyParallel(java.util.Collection collection, groovy.lang.Closure cl)

static java.lang.Object findAnyParallel(java.lang.Object collection, groovy.lang.Closure cl)

static java.util.Map$Entry findAnyParallel(java.util.Map collection, groovy.lang.Closure cl)

static java.lang.Object findParallel(java.util.Collection collection, groovy.lang.Closure cl)

static java.lang.Object findParallel(java.lang.Object collection, groovy.lang.Closure cl)

static java.util.Map$Entry findParallel(java.util.Map collection, groovy.lang.Closure cl)

static java.lang.Object foldParallel(java.util.Collection collection, 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.

static java.lang.Object foldParallel(java.lang.Object collection, 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.

static java.lang.Object foldParallel(java.util.Collection collection, 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.

static java.lang.Object foldParallel(java.lang.Object collection, 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.

static PAWrapper getParallel(java.util.Collection collection)

Creates a ParallelArray wrapping the elements of the original collection.

static PAWrapper getParallel(java.lang.Object collection)

Creates a ParallelArray wrapping the elements of the original collection.

static ParallelArray getParallelArray(java.util.Collection collection)

static ParallelArray getParallelArray(java.lang.Object collection)

static groovy.lang.Closure gmemoize(groovy.lang.Closure cl)

static groovy.lang.Closure gmemoizeAtLeast(groovy.lang.Closure cl, int protectedCacheSize)

static groovy.lang.Closure gmemoizeAtMost(groovy.lang.Closure cl, int maxCacheSize)

static groovy.lang.Closure gmemoizeBetween(groovy.lang.Closure cl, int protectedCacheSize, int maxCacheSize)

static java.util.Collection grepParallel(java.util.Collection collection, java.lang.Object filter)

static java.lang.Object grepParallel(java.lang.Object collection, java.lang.Object filter)

static java.util.Map grepParallel(java.util.Map collection, java.lang.Object filter)

Creates a Parallel Array out of the supplied collection/object and invokes the withFilter() method using the supplied rule as the filter predicate.

static java.util.Map groupByParallel(java.util.Collection collection, groovy.lang.Closure cl)

static java.util.Map groupByParallel(java.lang.Object collection, groovy.lang.Closure cl)

private static java.util.Map groupByParallelPA(ParallelArray pa, groovy.lang.Closure cl)

static java.lang.Object injectParallel(java.util.Collection collection, 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.

static java.lang.Object injectParallel(java.lang.Object collection, 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.

static java.lang.Object injectParallel(java.util.Collection collection, 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.

static java.lang.Object injectParallel(java.lang.Object collection, java.lang.Object seed, groovy.lang.Closure cl)

Creates a PAWrapper around a ParallelArray wrapping the elements of the original collection.

static boolean isConcurrent(java.lang.Object collection)

static java.util.concurrent.Future leftShift(ForkJoinPool pool, groovy.lang.Closure task)

Creates an asynchronous variant of the supplied closure, which, when invoked returns a future for the potential return value

static java.lang.Object makeConcurrent(java.lang.Object collection)

Gives the iterative methods like each() or find() the original sequential semantics.

static java.lang.Object makeSequential(java.lang.Object collection)

static java.lang.Object maxParallel(java.util.Collection collection, groovy.lang.Closure cl)

static java.lang.Object maxParallel(java.lang.Object collection, groovy.lang.Closure cl)

Creates a Parallel Array out of the supplied collection/object and invokes its max() method using the default comparator.

static java.lang.Object maxParallel(java.util.Collection collection)

Creates a Parallel Array out of the supplied collection/object and invokes its max() method using the default comparator.

static java.lang.Object maxParallel(java.lang.Object collection)

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.

static java.lang.Object minParallel(java.util.Collection collection, groovy.lang.Closure cl)

static java.lang.Object minParallel(java.lang.Object collection, groovy.lang.Closure cl)

Creates a Parallel Array out of the supplied collection/object and invokes its min() method using the default comparator.

static java.lang.Object minParallel(java.util.Collection collection)

Creates a Parallel Array out of the supplied collection/object and invokes its min() method using the default comparator.

static java.lang.Object minParallel(java.lang.Object collection)

private static ForkJoinPool retrievePool()

static java.util.Collection splitParallel(java.util.Collection collection, java.lang.Object filter)

static java.lang.Object splitParallel(java.lang.Object collection, java.lang.Object filter)

static java.lang.Object sumParallel(java.util.Collection collection)

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.

static java.lang.Object sumParallel(java.lang.Object collection)

Creates a Parallel Array out of the supplied collection/object and invokes its reduce() method using the supplied closure as the reduction operation.

 
Methods inherited from class java.lang.Object
java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), 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()
 

Field Detail

timer

private static final GeneralTimer timer


 
Constructor Detail

GParsPoolUtil

GParsPoolUtil()


 
Method Detail

anyParallel

public static boolean anyParallel(java.util.Collection collection, groovy.lang.Closure cl)


anyParallel

public static boolean anyParallel(java.lang.Object collection, groovy.lang.Closure cl)


anyParallel

public static boolean anyParallel(java.util.Map collection, groovy.lang.Closure cl)


asConcurrent

public static void asConcurrent(java.lang.Object collection, groovy.lang.Closure code)
Indicates whether the iterative methods like each() or collect() work have been altered to work concurrently.


async

public static groovy.lang.Closure async(groovy.lang.Closure cl)
Creates an asynchronous and composable variant of the supplied closure, which, when invoked returns a DataflowVariable for the potential return value


asyncFun

public static groovy.lang.Closure asyncFun(groovy.lang.Closure original)
Creates an asynchronous and composable variant of the supplied closure, which, when invoked returns a DataflowVariable for the potential return value


asyncFun

public static groovy.lang.Closure asyncFun(groovy.lang.Closure original, boolean blocking)
Creates an asynchronous and composable variant of the supplied closure, which, when invoked returns a DataflowVariable for the potential return value


asyncFun

public static groovy.lang.Closure asyncFun(groovy.lang.Closure original, FJPool pool)


asyncFun

public static groovy.lang.Closure asyncFun(groovy.lang.Closure original, FJPool pool, boolean blocking)


callAsync

public static java.util.concurrent.Future callAsync(groovy.lang.Closure cl, java.lang.Object... args)


callParallel

public static java.util.concurrent.Future callParallel(groovy.lang.Closure task)
Calls a closure in a separate thread supplying the given arguments, returning a future for the potential return value.


callTimeoutAsync

public static java.util.concurrent.Future callTimeoutAsync(groovy.lang.Closure cl, long timeout, java.lang.Object... args)


callTimeoutAsync

public static java.util.concurrent.Future callTimeoutAsync(groovy.lang.Closure cl, groovy.time.Duration timeout, java.lang.Object... args)
Submits the task for asynchronous processing returning the Future received from the executor service. Allows for the following syntax:
 executorService << {println 'Inside parallel task'}
 


collectManyParallel

public static java.util.List collectManyParallel(java.util.Collection collection, groovy.lang.Closure projection)


collectManyParallel

public static java.util.List collectManyParallel(java.lang.Object collection, groovy.lang.Closure projection)


collectManyParallel

public static java.util.List collectManyParallel(java.util.Map collection, groovy.lang.Closure projection)


collectParallel

public static java.util.Collection collectParallel(java.util.Collection collection, groovy.lang.Closure cl)


collectParallel

public static java.util.Collection collectParallel(java.lang.Object collection, groovy.lang.Closure cl)


collectParallel

public static java.util.Collection collectParallel(java.util.Map collection, groovy.lang.Closure cl)


countParallel

public static int countParallel(java.util.Collection collection, java.lang.Object filter)


countParallel

public static int countParallel(java.lang.Object collection, java.lang.Object filter)


countParallel

public static int countParallel(java.util.Collection collection, groovy.lang.Closure filter)


countParallel

public static int countParallel(java.lang.Object collection, groovy.lang.Closure filter)


createPA

private static ParallelArray createPA(java.util.Map collection, ForkJoinPool pool)
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().
Parameters:
collection - The object to make transparent
Returns:
The instance of the TransparentParallel class wrapping the original object and overriding the iterative methods with new parallel behavior


eachParallel

public static java.util.Collection eachParallel(java.util.Collection collection, groovy.lang.Closure cl)


eachParallel

public static java.lang.Object eachParallel(java.lang.Object collection, groovy.lang.Closure cl)


eachParallel

public static java.util.Map eachParallel(java.util.Map collection, groovy.lang.Closure cl)


eachWithIndexParallel

public static java.util.Collection eachWithIndexParallel(java.util.Collection collection, groovy.lang.Closure cl)


eachWithIndexParallel

public static java.lang.Object eachWithIndexParallel(java.lang.Object collection, groovy.lang.Closure cl)
Does parallel eachWithIndex on maps


eachWithIndexParallel

public static java.util.Map eachWithIndexParallel(java.util.Map collection, groovy.lang.Closure cl)


everyParallel

public static boolean everyParallel(java.util.Collection collection, groovy.lang.Closure cl)


everyParallel

public static boolean everyParallel(java.lang.Object collection, groovy.lang.Closure cl)


everyParallel

public static boolean everyParallel(java.util.Map collection, groovy.lang.Closure cl)


findAllParallel

public static java.util.Collection findAllParallel(java.util.Collection collection, groovy.lang.Closure cl)


findAllParallel

public static java.util.Collection findAllParallel(java.lang.Object collection, groovy.lang.Closure cl)


findAllParallel

public static java.util.Map findAllParallel(java.util.Map collection, groovy.lang.Closure cl)


findAnyParallel

public static java.lang.Object findAnyParallel(java.util.Collection collection, groovy.lang.Closure cl)


findAnyParallel

public static java.lang.Object findAnyParallel(java.lang.Object collection, groovy.lang.Closure cl)


findAnyParallel

public static java.util.Map$Entry findAnyParallel(java.util.Map collection, groovy.lang.Closure cl)


findParallel

@java.lang.SuppressWarnings* GParsPool.withPool {
public static java.lang.Object findParallel(java.util.Collection collection, groovy.lang.Closure cl)


findParallel

public static java.lang.Object findParallel(java.lang.Object collection, groovy.lang.Closure cl)


findParallel

public static java.util.Map$Entry findParallel(java.util.Map collection, groovy.lang.Closure cl)


foldParallel

@java.lang.SuppressWarningspublic static Object foldParallel(final Object collection, final Closure cl) {
@java.lang.Deprecatedreturn GParsPoolUtilHelper.createPA(collection, retrievePool()).reduce(new ClosureReducer(cl), null);
public static java.lang.Object foldParallel(java.util.Collection collection, 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. 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 reduce(Closure cl) method, which delegates to the GParsPoolUtil class.


foldParallel

@java.lang.Deprecated
public static java.lang.Object foldParallel(java.lang.Object collection, 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. 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 reduce(Closure cl) method, which delegates to the GParsPoolUtil class.
Parameters:
seed - A seed value to initialize the operation


foldParallel

@java.lang.Deprecated
public static java.lang.Object foldParallel(java.util.Collection collection, 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. 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 reduce(Closure cl) method, which delegates to the GParsPoolUtil class.
Parameters:
seed - A seed value to initialize the operation


foldParallel

@java.lang.Deprecatedreturn GParsPoolUtilHelper.createPAFromCollection(collection, retrievePool()).reduce(new ClosureReducer(cl), null);
public static java.lang.Object foldParallel(java.lang.Object collection, 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. 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 reduce(Closure cl) method, which delegates to the GParsPoolUtil class.


getParallel

public static PAWrapper getParallel(java.util.Collection collection)
Creates a ParallelArray wrapping the elements of the original collection.


getParallel

public static PAWrapper getParallel(java.lang.Object collection)
Creates a ParallelArray wrapping the elements of the original collection.


getParallelArray

@java.lang.SuppressWarnings
public static ParallelArray getParallelArray(java.util.Collection collection)


getParallelArray

public static ParallelArray getParallelArray(java.lang.Object collection)


gmemoize

@java.lang.Deprecated* 

public static groovy.lang.Closure gmemoize(groovy.lang.Closure cl)


gmemoizeAtLeast

@java.lang.Deprecated* Cached entries exceeding the specified preservation threshold are made available for eviction based on
public static groovy.lang.Closure gmemoizeAtLeast(groovy.lang.Closure cl, int protectedCacheSize)


gmemoizeAtMost

@java.lang.Deprecated* Cached entries exceeding the specified preservation threshold are made available for eviction based on
public static groovy.lang.Closure gmemoizeAtMost(groovy.lang.Closure cl, int maxCacheSize)


gmemoizeBetween

@java.lang.Deprecated
public static groovy.lang.Closure gmemoizeBetween(groovy.lang.Closure cl, int protectedCacheSize, int maxCacheSize)


grepParallel

public static java.util.Collection grepParallel(java.util.Collection collection, java.lang.Object filter)


grepParallel

public static java.lang.Object grepParallel(java.lang.Object collection, java.lang.Object filter)


grepParallel

public static java.util.Map grepParallel(java.util.Map collection, java.lang.Object filter)
Creates a Parallel Array out of the supplied collection/object and invokes the withFilter() method using the supplied rule as the filter predicate. The filter will be effectively used concurrently on the elements of the collection. After all the elements have been processed, the method returns a collection of values from the resulting Parallel Array. 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 grepParallel(Closure cl) method, which delegates to the GParsPoolUtil class.


groupByParallel

public static java.util.Map groupByParallel(java.util.Collection collection, groovy.lang.Closure cl)


groupByParallel

public static java.util.Map groupByParallel(java.lang.Object collection, groovy.lang.Closure cl)


groupByParallelPA

private static java.util.Map groupByParallelPA(ParallelArray pa, groovy.lang.Closure cl)


injectParallel

@java.lang.SuppressWarnings}
public static java.lang.Object injectParallel(java.util.Collection collection, 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. 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 reduce(Closure cl) method, which delegates to the GParsPoolUtil class.


injectParallel

public static java.lang.Object injectParallel(java.lang.Object collection, 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. 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 reduce(Closure cl) method, which delegates to the GParsPoolUtil class.
Parameters:
seed - A seed value to initialize the operation


injectParallel

public static java.lang.Object injectParallel(java.util.Collection collection, 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. 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 reduce(Closure cl) method, which delegates to the GParsPoolUtil class.
Parameters:
seed - A seed value to initialize the operation


injectParallel

public static java.lang.Object injectParallel(java.lang.Object collection, java.lang.Object seed, groovy.lang.Closure cl)
Creates a PAWrapper around a ParallelArray wrapping the elements of the original collection. This allows further parallel processing operations on the collection to chain and so effectively leverage the underlying ParallelArray implementation.


isConcurrent

public static boolean isConcurrent(java.lang.Object collection)


leftShift

public static java.util.concurrent.Future leftShift(ForkJoinPool pool, groovy.lang.Closure task)
Creates an asynchronous variant of the supplied closure, which, when invoked returns a future for the potential return value


makeConcurrent

public static java.lang.Object makeConcurrent(java.lang.Object collection)
Gives the iterative methods like each() or find() the original sequential semantics.
Parameters:
collection - The collection to apply the change to
Returns:
The collection itself


makeSequential

public static java.lang.Object makeSequential(java.lang.Object collection)


maxParallel

@java.lang.SuppressWarnings* @param cl A one or two-argument closure
public static java.lang.Object maxParallel(java.util.Collection collection, groovy.lang.Closure cl)


maxParallel

public static java.lang.Object maxParallel(java.lang.Object collection, groovy.lang.Closure cl)
Creates 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 max(Closure cl) method, which delegates to the GParsPoolUtil class.


maxParallel

@java.lang.SuppressWarnings/**
public static java.lang.Object maxParallel(java.util.Collection collection)
Creates 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 max(Closure cl) method, which delegates to the GParsPoolUtil class.


maxParallel

public static java.lang.Object maxParallel(java.lang.Object collection)
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 sun(Closure cl) method, which delegates to the GParsPoolUtil class.


minParallel

@java.lang.SuppressWarnings* @param cl A one or two-argument closure
public static java.lang.Object minParallel(java.util.Collection collection, groovy.lang.Closure cl)


minParallel

public static java.lang.Object minParallel(java.lang.Object collection, groovy.lang.Closure cl)
Creates 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.


minParallel

@java.lang.SuppressWarnings/**
public static java.lang.Object minParallel(java.util.Collection collection)
Creates 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.


minParallel

public static java.lang.Object minParallel(java.lang.Object collection)


retrievePool

private static ForkJoinPool retrievePool()


splitParallel

public static java.util.Collection splitParallel(java.util.Collection collection, java.lang.Object filter)


splitParallel

public static java.lang.Object splitParallel(java.lang.Object collection, java.lang.Object filter)


sumParallel

public static java.lang.Object sumParallel(java.util.Collection collection)
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 sum(Closure cl) method, which delegates to the GParsPoolUtil class.


sumParallel

public static java.lang.Object sumParallel(java.lang.Object collection)
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 reduce(Closure cl) method, which delegates to the GParsPoolUtil class.


 

Copyright © 2008–2013 Václav Pech. All Rights Reserved.