org.codehaus.gpars

groovyx.gpars.util
[Java] Class PAUtils

java.lang.Object
  groovyx.gpars.util.PAUtils

@SuppressWarnings({"UtilityClass", "AbstractClassWithoutAbstractMethods", "AbstractClassNeverImplemented", "StaticMethodOnlyUsedInOneClass"})
public abstract class PAUtils

Handy methods build PA from different types

Authors:
Vaclav Pech Date: 24th Oct 2010


Constructor Summary
PAUtils()

 
Method Summary
static groovy.lang.Closure buildClosureForMaps(groovy.lang.Closure cl)

If the passed-in closure expects two arguments, it is considered to be a map-iterative code and is then wrapped with a single-argument closure, which unwraps the key:value pairs for the original closure.

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

If the passed-in closure expects three arguments, it is considered to be a map-iterative_with_index code and is then wrapped with a two-argument closure, which unwraps the key:value pairs for the original closure.

static java.util.Map buildResultMap(java.util.Collection result)

Builds a resulting map out of an map entry collection

static java.lang.String[] createArray(java.lang.CharSequence value)

static java.util.Map$Entry[] createArray(java.util.Map map)

static java.util.Collection createCollection(java.lang.Iterable object)

static java.util.Collection createCollection(java.util.Iterator iterator)

static java.util.Comparator createComparator(groovy.lang.Closure handler)

Builds a comparator depending on the number of arguments accepted by the supplied closure.

static groovy.lang.Closure createGroupByClosure(groovy.lang.Closure cl, java.util.concurrent.ConcurrentMap map)

Creates a closure that will insert elements in the appropriate group

static void evaluateArguments(Pool pool, java.lang.Object[] args, int current, java.util.List soFarArgs, DataflowVariable result, groovy.lang.Closure original, boolean pooledThreadFlag)

Performs a single step in the evaluation of parameters passed into an asynchronous function

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

Constructor Detail

PAUtils

PAUtils()


 
Method Detail

buildClosureForMaps

public static groovy.lang.Closure buildClosureForMaps(groovy.lang.Closure cl)
If the passed-in closure expects two arguments, it is considered to be a map-iterative code and is then wrapped with a single-argument closure, which unwraps the key:value pairs for the original closure. If the supplied closure doesn't expect two arguments, it is returned unchanged.
Parameters:
cl - The closure to use for parallel methods
Returns:
The original or an unwrapping closure


buildClosureForMapsWithIndex

public static groovy.lang.Closure buildClosureForMapsWithIndex(groovy.lang.Closure cl)
If the passed-in closure expects three arguments, it is considered to be a map-iterative_with_index code and is then wrapped with a two-argument closure, which unwraps the key:value pairs for the original closure. If the supplied closure doesn't expect three arguments, it is returned unchanged.
Parameters:
cl - The closure to use for parallel methods
Returns:
The original or an unwrapping closure


buildResultMap

public static java.util.Map buildResultMap(java.util.Collection result)
Builds a resulting map out of an map entry collection
Parameters:
result - The collection containing map entries
Returns:
A corresponding map instance


createArray

public static java.lang.String[] createArray(java.lang.CharSequence value)


createArray

public static java.util.Map$Entry[] createArray(java.util.Map map)


createCollection

public static java.util.Collection createCollection(java.lang.Iterable object)


createCollection

public static java.util.Collection createCollection(java.util.Iterator iterator)


createComparator

public static java.util.Comparator createComparator(groovy.lang.Closure handler)
Builds a comparator depending on the number of arguments accepted by the supplied closure.
Parameters:
handler - The one or two argument closure to build a comparator on
Returns:
A new Comparator to use


createGroupByClosure

public static groovy.lang.Closure createGroupByClosure(groovy.lang.Closure cl, java.util.concurrent.ConcurrentMap map)
Creates a closure that will insert elements in the appropriate group
Parameters:
cl - The distinction closure
map - The map of groups to contribute to
Returns:
null


evaluateArguments

@SuppressWarnings({"unchecked"})
public static void evaluateArguments(Pool pool, java.lang.Object[] args, int current, java.util.List soFarArgs, DataflowVariable result, groovy.lang.Closure original, boolean pooledThreadFlag)
Performs a single step in the evaluation of parameters passed into an asynchronous function
Parameters:
pool - The thread pool to use
args - The list of original arguments
current - The index of the current argument to evaluate
soFarArgs - A list of arguments evaluated so far
result - The DFV expecting the function result to be bound to once calculated
original - The original non-asynchronous function to invoke once all arguments are available
pooledThreadFlag - Indicates, whether we now run in a pooled thread so we don't have to schedule the original function invocation, once all arguments have been bound


 

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