T - the type of the eventual value of the PartialFuturepublic abstract class AbstractPartialFuture<T> extends Object implements Disposable, PartialFuture<T>
PartialFuture interface. This class should
generally only be useful to the advanced user of the FoundationDB Async library for
creating new types of native-backed futures.| Constructor and Description |
|---|
AbstractPartialFuture(Executor executor) |
AbstractPartialFuture(long cPtr,
Executor executor)
Deprecated.
|
| Modifier and Type | Method and Description |
|---|---|
void |
dispose()
Dispose of the object.
|
<V> PartialFuture<V> |
flatMap(PartialFunction<? super T,? extends PartialFuture<V>> m)
Applies the successful result of this operation as the input into another asynchronous
operation and returns a handle to that result.
|
T |
get()
Blocks until a value is set on this
PartialFuture and returns it. |
T |
getInterruptibly()
Blocks until a value is set on this
PartialFuture and returns it. |
<V> PartialFuture<V> |
map(PartialFunction<? super T,V> m)
Apply a function to the successful result of this operation.
|
void |
onReady(Runnable r)
Registers a
Runnable to run as the callback for this Future
on a default thread. |
boolean |
onReadyAlready(Runnable r)
Checks if this
Future is ready and, if not, atomically registers a
Runnable to run as the callback for this future on a default thread. |
Future<T> |
rescue(Function<? super Exception,Future<T>> m)
Convert an error output of this operation into another asynchronous process.
|
PartialFuture<T> |
rescue(PartialFunction<? super Exception,? extends PartialFuture<T>> m)
Map any error result of this
Future to another asynchronous process. |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitblockInterruptibly, blockUntilReady, cancel, getError, isDone, isErrorpublic AbstractPartialFuture(Executor executor)
@Deprecated public AbstractPartialFuture(long cPtr, Executor executor)
public void onReady(Runnable r)
PartialFutureRunnable to run as the callback for this Future
on a default thread. It will be called after the future becomes ready, including
if the future is set to a value, set to an error, or cancelled.PartialFuture.map(PartialFunction) and PartialFuture.flatMap(PartialFunction)
instead, as they automatically provide error propagation and cancellation.onReady in interface PartialFuture<T>r - the code to run when the future is set either to value or errorpublic boolean onReadyAlready(Runnable r)
PartialFutureFuture is ready and, if not, atomically registers a
Runnable to run as the callback for this future on a default thread. The
callback will not be called if the future is ready. Callers can rely on the guarantee
that if this function returns false their callback will be executed on
completion (including if the future is set to a value, set to an error, or cancelled),
and if true they can then call PartialFuture.get() without blocking.onReadyAlready in interface PartialFuture<T>r - the code to run when the future is set if it is not currently readytrue if the future is ready, false otherwisepublic <V> PartialFuture<V> flatMap(PartialFunction<? super T,? extends PartialFuture<V>> m)
PartialFutureFuture is complete and a result
is returned, the Mapper m is invoked to begin a new asynchronous process
using the result.
Errors in the execution of either operation are sent to the resulting Future.Future is cancelled the input
input Future will also be cancelled.flatMap in interface PartialFuture<T>m - the map to the asynchronous process to be runFuture that passes errors and converts output of this Future
to the output of another asynchronous process.public <V> PartialFuture<V> map(PartialFunction<? super T,V> m)
PartialFutureFuture.Future is cancelled the input
input Future will also be cancelled.map in interface PartialFuture<T>m - the map to the conversion to be runFuture that passes errors and converts output of this Future.public Future<T> rescue(Function<? super Exception,Future<T>> m)
PartialFuturerescue in interface PartialFuture<T>m - the process to run on completion into error state.Future output with modified error behaviorpublic PartialFuture<T> rescue(PartialFunction<? super Exception,? extends PartialFuture<T>> m)
PartialFutureFuture to another asynchronous process. This can be
used when an error is expected or can be logically dealt with in some way. If the
rescue process cannot handle the error, or if the rescue process itself throws an error,
that error will be set on this Future. If the result
of this call is used in place of this Future, the user of the output
Future
will see successes of this process, successes of the rescue process, or errors from
the rescue process.rescue in interface PartialFuture<T>m - the process to run that maps an error into another asynchronous operationFuture with modified error behaviorpublic T get() throws Exception
PartialFuturePartialFuture and returns it.
If this PartialFuture is set to an Exception or Error
this call will throw that error.get in interface PartialFuture<T>Exception - if the process was not successfully executed.InterruptedException - if the blocked thread is interruptedpublic T getInterruptibly() throws Exception
PartialFuturePartialFuture and returns it.
If this PartialFuture is set to an Exception or Error
this call will throw that error.getInterruptibly in interface PartialFuture<T>Exception - if the process was not successfully executed.InterruptedException - if the blocked thread is interruptedpublic void dispose()
Disposabledispose in interface PartialFuture<T>dispose in interface Disposable