GParsExecutorsPoolEnhancer allows classes or instances to be enhanced with asynchronous variants of iterative methods, like eachParallel(), collectParallel(), findAllParallel() and others. These operations split processing into multiple concurrently executable tasks and perform them on the underlying instance of an ExecutorService. The pool itself is stored in a final property threadPool and can be managed through static methods on the GParsExecutorsPoolEnhancer class. All enhanced classes and instances will share the underlying pool.
Modifiers | Name | Description |
---|---|---|
private static DefaultPool |
threadPool |
Holds the internal ExecutorService instance wrapped into a DefaultPool |
Constructor and description |
---|
GParsExecutorsPoolEnhancer
() |
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. |
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 |
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. |
static void |
enhanceClass(java.lang.Class clazz) Enhances a class and so all instances created in the future by mixing-in an instance of GParsExecutorsPoolEnhancer. |
static void |
enhanceInstance(java.lang.Object collection) Enhances a single instance by mixing-in an instance of GParsExecutorsPoolEnhancer. |
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 |
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. |
Pool |
getThreadPool() Retrieves the underlying pool |
java.lang.Object |
grepParallel(groovy.lang.Closure cl) 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. |
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() |
Holds the internal ExecutorService instance wrapped into a DefaultPool
Performs the any() 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.
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.
Iterates over a collection/object with the each() method using an asynchronous variant of the supplied closure to evaluate each collection's element. A CountDownLatch is used to make the calling thread wait for all the results. 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.
Iterates over a collection/object with the eachWithIndex() method using an asynchronous variant of the supplied closure to evaluate each collection's element. A CountDownLatch is used to make the calling thread wait for all the results. 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.
Enhances a class and so all instances created in the future by mixing-in an instance of GParsExecutorsPoolEnhancer. Enhancing classes needs to be done with caution, since it may have impact in unrelated parts of the application.
Enhances a single instance by mixing-in an instance of GParsExecutorsPoolEnhancer.
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.
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.
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.
Retrieves the underlying pool
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.
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.
Copyright © 2008–2014 Václav Pech. All Rights Reserved.