|
Copyright 2008 - 2010 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.Promise<A>
public final class Promise<A>
Represents a non-blocking future value. Products, functions, and actors, given to the methods on this class, are executed concurrently, and the Promise serves as a handle on the result of the computation. Provides monadic operations so that future computations can be combined
Author: Runar
| Method Summary | ||
|---|---|---|
|
apply(Promise<F<A,B>> pf)
Performs function application within a promise (applicative functor pattern). |
|
|
bind(F<A,Promise<B>> f)
Binds the given function over this promise, with a final join. |
|
|
bind(P1<Promise<B>> p,
F<A,F<B,C>> f)
Binds the given function to this promise and the given promise, with a final join. |
|
|
bind(Promise<B> pb,
F<A,F<B,C>> f)
Binds the given function to this promise and the given promise, with a final join. |
|
A |
claim()
Waits if necessary for the computation to complete, and then retrieves its result. |
|
Option<A> |
claim(long timeout,
java.util.concurrent.TimeUnit unit)
Waits if necessary for the computation to complete, and then retrieves its result. |
|
|
cobind(F<Promise<A>,B> f)
Binds the given function across a promise of this promise (Comonad pattern). |
|
Promise<Promise<A>> |
cojoin()
Duplicates this promise to a promise of itself (Comonad pattern). |
|
static
|
fmap_(F<A,B> f)
Promotes any function to a transformation between promises (covariant functor pattern). |
|
|
fmap(F<A,B> f)
Provides a promise to apply the given function to this promise's future value (covariant functor pattern). |
|
static
|
foldRight(Strategy<Unit> s,
F<A,F<B,B>> f,
B b)
Performs a right-fold reduction across a list in constant stack space. |
|
static
|
foldRightS(Strategy<Unit> s,
F<A,F<P1<B>,B>> f,
B b)
Performs a right-fold reduction across a Stream in constant stack space. |
|
boolean |
isFulfilled()
Returns true if this promise has been fulfilled. |
|
static
|
join(Promise<Promise<A>> p)
Turns a promise of a promise into just a promise. |
|
static
|
join(Strategy<Unit> s,
P1<Promise<A>> p)
Turns a product of a promise into just a promise. |
|
static
|
liftM2(F<A,F<B,C>> f)
Promotes a function of arity-2 to a function on promises. |
|
static
|
promise(Strategy<Unit> s)
Provides a first-class unit function for promises. |
|
static
|
promise(Strategy<Unit> s,
java.util.concurrent.Callable<A> a)
Provides a promise to call the given Callable in the future. |
|
static
|
promise(Strategy<Unit> s,
F<A,B> f)
Transforms any function so that it returns a promise of a value instead of an actual value. |
|
static
|
promise(Strategy<Unit> s,
P1<A> a)
Promises to provide the value of the given 1-product, in the future. |
|
static
|
sequence(Strategy<Unit> s)
First-class version of the sequence function through a List. |
|
static
|
sequence(Strategy<Unit> s,
List<Promise<A>> as)
Turns a List of promises into a single promise of a List. |
|
static
|
sequence(Strategy<Unit> s,
P1<Promise<A>> p)
Transforms a product of a promise to a promise of a product. |
|
static
|
sequence(Strategy<Unit> s,
Stream<Promise<A>> as)
Turns a Stream of promises into a single promise of a Stream. |
|
static
|
sequenceS(Strategy<Unit> s)
First-class version of the sequence function through a Stream. |
|
|
sequenceW(Stream<F<Promise<A>,B>> fs)
Applies a stream of comonadic functions to this promise, returning a stream of values. |
|
void |
to(Actor<A> a)
Promises to send a value to the given actor in the future. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static <A> Promise<A> promise(Strategy<Unit> s,
P1<A> a)
s - The strategy with which to fulfil the promise.a - The 1-product to evaluate concurrently.
public static <A> F<P1<A>,Promise<A>> promise(Strategy<Unit> s)
s - The strategy with which to fulfil promises.
public static <A> Promise<java.util.concurrent.Callable<A>> promise(Strategy<Unit> s,
java.util.concurrent.Callable<A> a)
s - The strategy with which to fulfil the promise.a - The Callable to evaluate concurrently.
public static <A,B> F<A,Promise<B>> promise(Strategy<Unit> s,
F<A,B> f)
s - The strategy with which to fulfil the promise.f - The function to turn into a promise-valued function.
public void to(Actor<A> a)
a - An actor that will receive this Promise's value in the future.public <B> Promise<B> fmap(F<A,B> f)
f - The function to apply to this promise's future value.
public static <A,B> F<Promise<A>,Promise<B>> fmap_(F<A,B> f)
f - The function to promote to a transformation between promises.
public static <A> Promise<A> join(Promise<Promise<A>> p)
p - A promise of a promise.
public static <A> Promise<A> join(Strategy<Unit> s,
P1<Promise<A>> p)
s - The strategy with which to fulfil the promise.p - A product-1 of a promise to turn into just a promise.
public <B> Promise<B> bind(F<A,Promise<B>> f)
f - The function to bind over this promise.
public <B> Promise<B> apply(Promise<F<A,B>> pf)
pf - The promised function to apply.
public <B,C> Promise<C> bind(Promise<B> pb,
F<A,F<B,C>> f)
pb - A promise with which to bind the given function.f - The function to apply to the given promised values.
public <B,C> Promise<C> bind(P1<Promise<B>> p,
F<A,F<B,C>> f)
p - A promise with which to bind the given function.f - The function to apply to the given promised values.
public static <A,B,C> F<Promise<A>,F<Promise<B>,Promise<C>>> liftM2(F<A,F<B,C>> f)
f - The function to promote.
public static <A> Promise<List<A>> sequence(Strategy<Unit> s,
List<Promise<A>> as)
s - The strategy with which to sequence the promises.as - The list of promises to transform.
public static <A> F<List<Promise<A>>,Promise<List<A>>> sequence(Strategy<Unit> s)
s - The strategy with which to sequence a given list of promises.
public static <A> Promise<Stream<A>> sequence(Strategy<Unit> s,
Stream<Promise<A>> as)
s - The strategy with which to sequence the promises.as - The Stream of promises to transform.
public static <A> F<List<Promise<A>>,Promise<List<A>>> sequenceS(Strategy<Unit> s)
s - The strategy with which to sequence a given Stream of promises.
public static <A> Promise<P1<A>> sequence(Strategy<Unit> s,
P1<Promise<A>> p)
s - The strategy with which to traverse the promise.p - A product of a promise to traverse.
public static <A,B> F<List<A>,Promise<B>> foldRight(Strategy<Unit> s,
F<A,F<B,B>> f,
B b)
s - The strategy with which to fold the list.f - The function to apply on each element of the list.b - The beginning value to start the application from.
public static <A,B> F<Stream<A>,Promise<B>> foldRightS(Strategy<Unit> s,
F<A,F<P1<B>,B>> f,
B b)
s - The strategy with which to fold the Stream.f - The function to apply on each element of the Stream.b - The beginning value to start the application from.
public A claim()
public Option<A> claim(long timeout,
java.util.concurrent.TimeUnit unit)
timeout - the maximum time to waitunit - the time unit of the timeout argument
public boolean isFulfilled()
public <B> Promise<B> cobind(F<Promise<A>,B> f)
f - A function to apply within a new promise of this promise.
public Promise<Promise<A>> cojoin()
public <B> Stream<B> sequenceW(Stream<F<Promise<A>,B>> fs)
fs - A stream of functions to apply to this promise.
|
Copyright 2008 - 2010 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 | ||||||||