|
Copyright 2008 - 2009 Tony Morris, Runar Bjarnason, Tom Adams, Brad Clow, Ricky Clarkson, Nick Partridge, Jason Zaugg This software is released under an open source BSD licence. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectfj.control.parallel.Strategy<A>
public final class Strategy<A>
Functional-style parallel evaluation strategies. A Strategy is a method of evaluating a product-1, yielding another product-1 from which the result of its evaluation can be retrieved at a later time.
Method Summary | ||
---|---|---|
static
|
callableStrategy(Strategy<Callable<A>> s)
Provides a normalising strategy that fully evaluates its Callable argument. |
|
Strategy<A> |
comap(F<P1<A>,P1<A>> f)
Maps the given transformation across this strategy's codomain (Invariant Functor pattern). |
|
static
|
completionStrategy(CompletionService<A> s)
Provides a parallelization strategy that uses a CompletionService to control the method and degree of parallelism, and where each parallel task's completion is registered with the service. |
|
|
concurry(F<B,A> f)
Promotes a function to a concurrent function. |
|
|
concurry(F2<B,C,A> f)
Promotes a function of arity-2 to a concurrent function. |
|
static
|
discard()
Returns an Effect that waits for a given Future to obtain a value, discarding the value. |
|
Strategy<A> |
errorStrategy(Effect<Error> e)
Provides an error-handling strategy. |
|
static
|
errorStrategy(Strategy<A> s,
Effect<Error> e)
Provides an error-handling strategy. |
|
static
|
executorStrategy(ExecutorService s)
Provides a parallelization strategy that uses an ExecutorService to control the method and degree of parallelism. |
|
F<P1<A>,P1<A>> |
f()
Returns the functional representation of this Strategy, a function that evaluates a product-1. |
|
static
|
idStrategy()
Provides a strategy that performs no evaluation of its argument. |
|
Strategy<A> |
map(F<P1<A>,P1<A>> f)
Maps the given transformation across this strategy's domain (Invariant Functor pattern). |
|
static
|
mergeAll(List<Future<A>> xs)
Waits for every Future in a list to obtain a value, and collects those values in a list. |
|
static
|
obtain()
Returns a function which returns a product-1 which waits for the given Future to obtain a value. |
|
static
|
obtain(Future<A> t)
Provides a product-1 that waits for the given future to obtain a value. |
|
P1<A> |
par(P1<A> a)
Apply the strategy to the given product-1. |
|
static
|
parFlatMap(Strategy<Array<B>> s,
F<A,Array<B>> f,
Array<A> as)
Binds the given function in parallel across the given array, using the given strategy, with a final join. |
|
static
|
parFlatMap(Strategy<List<B>> s,
F<A,List<B>> f,
List<A> as)
Binds the given function in parallel across the given list, using the given strategy, with a final join. |
|
P1<List<A>> |
parList(List<P1<A>> ps)
Evaluates a list of product-1s in parallel. |
|
static
|
parListChunk(Strategy<List<A>> s,
int chunkLength,
List<P1<A>> as)
Sequentially evaluates chunks (sub-sequences) of a list in parallel. |
|
|
parMap(F<B,A> f,
Array<B> bs)
Maps the given function over the given array in parallel using this strategy. |
|
|
parMap(F<B,A> f,
List<B> bs)
Maps the given function over the given list in parallel using this strategy. |
|
|
parMap1(F<B,A> f,
Array<B> bs)
A strict version of parMap over arrays. |
|
|
parMap1(F<B,A> f,
List<B> bs)
A strict version of parMap over lists. |
|
|
parMapArray()
First-class version of parMap on arrays. |
|
|
parMapArray(F<B,A> f)
Promotes a function to a parallel function on arrays using this strategy. |
|
|
parMapArray1()
First-class version of parMap1 on arrays (parallel array functor). |
|
|
parMapList()
First-class version of parMap on lists. |
|
|
parMapList(F<B,A> f)
Promotes a function to a parallel function on lists using this strategy. |
|
|
parMapList1()
First-class version of parMap1 on lists (parallel list functor). |
|
|
parZipArrayWith(F2<B,C,A> f)
Lifts a given function of arity-2 so that it zips together two arrays in parallel, using this strategy, calling the function once for each corresponding pair in the arrays, position-wise. |
|
|
parZipListWith(F2<B,C,A> f)
Lifts a given function of arity-2 so that it zips together two lists in parallel, using this strategy, calling the function once for each corresponding pair in the lists, position-wise. |
|
|
parZipWith(F2<B,C,A> f,
Array<B> bs,
Array<C> cs)
Zips together two arrays in parallel using a given function, with this strategy. |
|
|
parZipWith(F2<B,C,A> f,
List<B> bs,
List<C> cs)
Zips together two lists in parallel using a given function, with this strategy. |
|
static
|
seqStrategy()
Provides a strategy that performs sequential (non-concurrent) evaluation of its argument. |
|
static
|
simpleThreadStrategy()
Provides a simple parallelization strategy that creates, and discards, a new thread for every evaluation. |
|
static
|
strategy(F<P1<A>,P1<A>> f)
Constructs a strategy from the given evaluation function. |
|
|
xmap(F<P1<A>,P1<B>> f,
F<P1<B>,P1<A>> g)
Maps the given bijective transformation across this strategy (Exponential Functor pattern). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public F<P1<A>,P1<A>> f()
public static <A> Strategy<A> strategy(F<P1<A>,P1<A>> f)
f
- The execution function for the strategy
public P1<A> par(P1<A> a)
a
- A P1 to evaluate according to this strategy.
public <B> F<B,P1<A>> concurry(F<B,A> f)
f
- A function to promote to a concurrent function.
public <B,C> F<B,F<C,P1<A>>> concurry(F2<B,C,A> f)
f
- The function to promote to a concurrent function.
public static <A> List<P1<A>> mergeAll(List<Future<A>> xs)
xs
- The list of Futures from which to get values.
public P1<List<A>> parList(List<P1<A>> ps)
ps
- A list to evaluate in parallel.
public <B> P1<List<A>> parMap(F<B,A> f, List<B> bs)
f
- A function to map over the given list in parallel.bs
- A list over which to map the given function in parallel.
public <B> P1<Array<A>> parMap(F<B,A> f, Array<B> bs)
f
- A function to map over the given array in parallel.bs
- An array over which to map the given function in parallel.
public <B> List<A> parMap1(F<B,A> f, List<B> bs)
f
- A function to map over the given list in parallel.bs
- A list over which to map the given function in parallel.
public <B> Array<A> parMap1(F<B,A> f, Array<B> bs)
f
- A function to map over the given array in parallel.bs
- An array over which to map the given function in parallel.
public <B> F<List<B>,P1<List<A>>> parMapList(F<B,A> f)
f
- A function to transform into a parallel function on lists.
public <B> F<F<B,A>,F<List<B>,P1<List<A>>>> parMapList()
public <B> F<F<B,A>,F<List<B>,List<A>>> parMapList1()
public <B> F<Array<B>,P1<Array<A>>> parMapArray(F<B,A> f)
f
- A function to transform into a parallel function on arrays.
public <B> F<F<B,A>,F<Array<B>,P1<Array<A>>>> parMapArray()
public <B> F<F<B,A>,F<Array<B>,Array<A>>> parMapArray1()
public static <A,B> P1<List<B>> parFlatMap(Strategy<List<B>> s, F<A,List<B>> f, List<A> as)
s
- The strategy to use for parallelization.f
- The function to bind across the given list.as
- The list across which to bind the given function.
public static <A,B> P1<Array<B>> parFlatMap(Strategy<Array<B>> s, F<A,Array<B>> f, Array<A> as)
s
- The strategy to use for parallelization.f
- The function to bind across the given array.as
- The array across which to bind the given function.
public static <A> P1<List<A>> parListChunk(Strategy<List<A>> s, int chunkLength, List<P1<A>> as)
s
- The strategy to use for parallelization.chunkLength
- The length of each sequence.as
- The list to evaluate in parallel chunks.
public <B,C> P1<List<A>> parZipWith(F2<B,C,A> f, List<B> bs, List<C> cs)
f
- The function of arity-2 with which to zip.bs
- A list to zip with the given function.cs
- A list to zip with the given function.
public <B,C> P1<Array<A>> parZipWith(F2<B,C,A> f, Array<B> bs, Array<C> cs)
f
- The function of arity-2 with which to zip.bs
- A array to zip with the given function.cs
- A array to zip with the given function.
public <B,C> F2<List<B>,List<C>,P1<List<A>>> parZipListWith(F2<B,C,A> f)
f
- The function of arity-2 with which to zip.
public <B,C> F2<Array<B>,Array<C>,P1<Array<A>>> parZipArrayWith(F2<B,C,A> f)
f
- The function of arity-2 with which to zip.
public static <A> F<Future<A>,P1<A>> obtain()
public static <A> P1<A> obtain(Future<A> t)
t
- A Future for which to wait.
public static <A> Effect<Future<A>> discard()
public static <A> Strategy<A> simpleThreadStrategy()
public static <A> Strategy<A> executorStrategy(ExecutorService s)
s
- The ExecutorService to use for scheduling evaluations.
public static <A> Strategy<A> completionStrategy(CompletionService<A> s)
s
- The CompletionService to use for scheduling evaluations and detect their completion.
public static <A> Strategy<A> seqStrategy()
public static <A> Strategy<A> idStrategy()
public <B> Strategy<B> xmap(F<P1<A>,P1<B>> f, F<P1<B>,P1<A>> g)
f
- A transformation from this strategy's codomain to the resulting strategy's codomain.g
- A transformation from the resulting strategy's domain to this strategy's domain.
public Strategy<A> map(F<P1<A>,P1<A>> f)
f
- A transformation from this strategy's codomain to the resulting strategy's codomain.
public Strategy<A> comap(F<P1<A>,P1<A>> f)
f
- A transformation from the resulting strategy's domain to this strategy's domain.
public Strategy<A> errorStrategy(Effect<Error> e)
e
- The effect that should handle errors.
public static <A> Strategy<A> errorStrategy(Strategy<A> s, Effect<Error> e)
s
- The strategy to equip with an error-handling effect.e
- The effect that should handle errors.
public static <A> Strategy<Callable<A>> callableStrategy(Strategy<Callable<A>> s)
s
- A non-normalising strategy to use for the evaluation.
|
Copyright 2008 - 2009 Tony Morris, Runar Bjarnason, Tom Adams, Brad Clow, Ricky Clarkson, Nick Partridge, Jason Zaugg This software is released under an open source BSD licence. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |