|
org.codehaus.gpars | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
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.
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 |
---|
private static final GeneralTimer timer
Constructor Detail |
---|
GParsPoolUtil()
Method Detail |
---|
public static boolean anyParallel(java.util.Collection collection, groovy.lang.Closure cl)
public static boolean anyParallel(java.lang.Object collection, groovy.lang.Closure cl)
public static boolean anyParallel(java.util.Map collection, groovy.lang.Closure cl)
public static void asConcurrent(java.lang.Object collection, groovy.lang.Closure code)
public static groovy.lang.Closure async(groovy.lang.Closure cl)
public static groovy.lang.Closure asyncFun(groovy.lang.Closure original)
public static groovy.lang.Closure asyncFun(groovy.lang.Closure original, boolean blocking)
public static groovy.lang.Closure asyncFun(groovy.lang.Closure original, FJPool pool)
public static groovy.lang.Closure asyncFun(groovy.lang.Closure original, FJPool pool, boolean blocking)
public static java.util.concurrent.Future callAsync(groovy.lang.Closure cl, java.lang.Object... args)
public static java.util.concurrent.Future callParallel(groovy.lang.Closure task)
public static java.util.concurrent.Future callTimeoutAsync(groovy.lang.Closure cl, long timeout, java.lang.Object... args)
public static java.util.concurrent.Future callTimeoutAsync(groovy.lang.Closure cl, groovy.time.Duration timeout, java.lang.Object... args)
executorService << {println 'Inside parallel task'}
public static java.util.List collectManyParallel(java.util.Collection collection, groovy.lang.Closure projection)
public static java.util.List collectManyParallel(java.lang.Object collection, groovy.lang.Closure projection)
public static java.util.List collectManyParallel(java.util.Map collection, groovy.lang.Closure projection)
public static java.util.Collection collectParallel(java.util.Collection collection, groovy.lang.Closure cl)
public static java.util.Collection collectParallel(java.lang.Object collection, groovy.lang.Closure cl)
public static java.util.Collection collectParallel(java.util.Map collection, groovy.lang.Closure cl)
public static int countParallel(java.util.Collection collection, java.lang.Object filter)
public static int countParallel(java.lang.Object collection, java.lang.Object filter)
public static int countParallel(java.util.Collection collection, groovy.lang.Closure filter)
public static int countParallel(java.lang.Object collection, groovy.lang.Closure filter)
private static ParallelArray createPA(java.util.Map collection, ForkJoinPool pool)
collection
- The object to make transparent
public static java.util.Collection eachParallel(java.util.Collection collection, groovy.lang.Closure cl)
public static java.lang.Object eachParallel(java.lang.Object collection, groovy.lang.Closure cl)
public static java.util.Map eachParallel(java.util.Map collection, groovy.lang.Closure cl)
public static java.util.Collection eachWithIndexParallel(java.util.Collection collection, groovy.lang.Closure cl)
public static java.lang.Object eachWithIndexParallel(java.lang.Object collection, groovy.lang.Closure cl)
public static java.util.Map eachWithIndexParallel(java.util.Map collection, groovy.lang.Closure cl)
public static boolean everyParallel(java.util.Collection collection, groovy.lang.Closure cl)
public static boolean everyParallel(java.lang.Object collection, groovy.lang.Closure cl)
public static boolean everyParallel(java.util.Map collection, groovy.lang.Closure cl)
public static java.util.Collection findAllParallel(java.util.Collection collection, groovy.lang.Closure cl)
public static java.util.Collection findAllParallel(java.lang.Object collection, groovy.lang.Closure cl)
public static java.util.Map findAllParallel(java.util.Map collection, groovy.lang.Closure cl)
public static java.lang.Object findAnyParallel(java.util.Collection collection, groovy.lang.Closure cl)
public static java.lang.Object findAnyParallel(java.lang.Object collection, groovy.lang.Closure cl)
public static java.util.Map$Entry findAnyParallel(java.util.Map collection, groovy.lang.Closure cl)
@java.lang.SuppressWarnings* GParsPool.withPool { public static java.lang.Object findParallel(java.util.Collection collection, groovy.lang.Closure cl)
public static java.lang.Object findParallel(java.lang.Object collection, groovy.lang.Closure cl)
public static java.util.Map$Entry findParallel(java.util.Map collection, groovy.lang.Closure cl)
@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)
withPool
block
have a new reduce(Closure cl)
method, which delegates to the GParsPoolUtil
class.
@java.lang.Deprecated public static java.lang.Object foldParallel(java.lang.Object collection, groovy.lang.Closure cl)
withPool
block
have a new reduce(Closure cl)
method, which delegates to the GParsPoolUtil
class.
seed
- A seed value to initialize the operation
@java.lang.Deprecated public static java.lang.Object foldParallel(java.util.Collection collection, java.lang.Object seed, groovy.lang.Closure cl)
withPool
block
have a new reduce(Closure cl)
method, which delegates to the GParsPoolUtil
class.
seed
- A seed value to initialize the operation
@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)
withPool
block
have a new reduce(Closure cl)
method, which delegates to the GParsPoolUtil
class.
public static PAWrapper getParallel(java.util.Collection collection)
public static PAWrapper getParallel(java.lang.Object collection)
@java.lang.SuppressWarnings public static ParallelArray getParallelArray(java.util.Collection collection)
public static ParallelArray getParallelArray(java.lang.Object collection)
@java.lang.Deprecated*public static groovy.lang.Closure gmemoize(groovy.lang.Closure cl)
@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)
@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)
@java.lang.Deprecated public static groovy.lang.Closure gmemoizeBetween(groovy.lang.Closure cl, int protectedCacheSize, int maxCacheSize)
public static java.util.Collection grepParallel(java.util.Collection collection, java.lang.Object filter)
public static java.lang.Object grepParallel(java.lang.Object collection, java.lang.Object filter)
public static java.util.Map grepParallel(java.util.Map collection, java.lang.Object filter)
withPool
block
have a new grepParallel(Closure cl)
method, which delegates to the GParsPoolUtil
class.
public static java.util.Map groupByParallel(java.util.Collection collection, groovy.lang.Closure cl)
public 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)
@java.lang.SuppressWarnings} public static java.lang.Object injectParallel(java.util.Collection collection, groovy.lang.Closure cl)
withPool
block
have a new reduce(Closure cl)
method, which delegates to the GParsPoolUtil
class.
public static java.lang.Object injectParallel(java.lang.Object collection, groovy.lang.Closure cl)
withPool
block
have a new reduce(Closure cl)
method, which delegates to the GParsPoolUtil
class.
seed
- A seed value to initialize the operation
public static java.lang.Object injectParallel(java.util.Collection collection, java.lang.Object seed, groovy.lang.Closure cl)
withPool
block
have a new reduce(Closure cl)
method, which delegates to the GParsPoolUtil
class.
seed
- A seed value to initialize the operation
public static java.lang.Object injectParallel(java.lang.Object collection, java.lang.Object seed, groovy.lang.Closure cl)
public static boolean isConcurrent(java.lang.Object collection)
public static java.util.concurrent.Future leftShift(ForkJoinPool pool, groovy.lang.Closure task)
public static java.lang.Object makeConcurrent(java.lang.Object collection)
collection
- The collection to apply the change to
public static java.lang.Object makeSequential(java.lang.Object collection)
@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)
public static java.lang.Object maxParallel(java.lang.Object collection, groovy.lang.Closure cl)
withPool
block
have a new max(Closure cl)
method, which delegates to the GParsPoolUtil
class.
@java.lang.SuppressWarnings/** public static java.lang.Object maxParallel(java.util.Collection collection)
withPool
block
have a new max(Closure cl)
method, which delegates to the GParsPoolUtil
class.
public static java.lang.Object maxParallel(java.lang.Object collection)
withPool
block
have a new sun(Closure cl)
method, which delegates to the GParsPoolUtil
class.
@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)
public static java.lang.Object minParallel(java.lang.Object collection, groovy.lang.Closure cl)
withPool
block
have a new min(Closure cl)
method, which delegates to the GParsPoolUtil
class.
@java.lang.SuppressWarnings/** public static java.lang.Object minParallel(java.util.Collection collection)
withPool
block
have a new min(Closure cl)
method, which delegates to the GParsPoolUtil
class.
public static java.lang.Object minParallel(java.lang.Object collection)
private static ForkJoinPool retrievePool()
public static java.util.Collection splitParallel(java.util.Collection collection, java.lang.Object filter)
public static java.lang.Object splitParallel(java.lang.Object collection, java.lang.Object filter)
public static java.lang.Object sumParallel(java.util.Collection collection)
withPool
block
have a new sum(Closure cl)
method, which delegates to the GParsPoolUtil
class.
public static java.lang.Object sumParallel(java.lang.Object collection)
withPool
block
have a new reduce(Closure cl)
method, which delegates to the GParsPoolUtil
class.
Copyright © 2008–2013 Václav Pech. All Rights Reserved.