T - The type being deferred.public class ConcurrentResolvableFuture<T> extends AbstractImmediateAsyncFuture<T> implements ResolvableFuture<T>
resolve(Object), and DeprecatedCompatAsyncFuture.on(FutureDone) for details.
It also allows for cancellation in any order.
Callback<Integer> callback = new ConcurrentCallback<Integer>(); new Thread(new Runnable() callback.resolve(12);).start(); callback.listen(new Callback.Handle() { ... }); }
| Modifier and Type | Field and Description |
|---|---|
static int |
CANCELLED |
static eu.toolchain.async.concurrent.ConcurrentResolvableFuture.RunnablePair |
END |
static int |
FAILED |
static int |
RESOLVED |
static int |
RESULT_UPDATING |
static int |
RUNNING |
async| Modifier | Constructor and Description |
|---|---|
|
ConcurrentResolvableFuture(AsyncFramework async,
AsyncCaller caller)
Setup a concurrent future that uses a custom caller implementation.
|
protected |
ConcurrentResolvableFuture(AsyncFramework async,
AsyncCaller caller,
eu.toolchain.async.concurrent.ConcurrentResolvableFuture.Sync sync) |
lazyTransformCancelled, lazyTransformFailed, lazyTransformResolved, transformCancelled, transformFailed, transformResolvedcancelled, cancelled, error, error, on, on, on, on, on, onAny, transform, transformpublic static final int RUNNING
public static final int RESULT_UPDATING
public static final int RESOLVED
public static final int FAILED
public static final int CANCELLED
public static final eu.toolchain.async.concurrent.ConcurrentResolvableFuture.RunnablePair END
public ConcurrentResolvableFuture(AsyncFramework async, AsyncCaller caller)
The provided caller implementation will be called from the calling thread of DeprecatedCompatAsyncFuture.on(eu.toolchain.async.FutureCancelled), or
other public methods interacting with this future.
It is therefore suggested to provide an implementation that supports delegating tasks to a separate thread pool.
async - The async implementation to use.caller - The caller implementation to use.protected ConcurrentResolvableFuture(AsyncFramework async, AsyncCaller caller, eu.toolchain.async.concurrent.ConcurrentResolvableFuture.Sync sync)
public boolean resolve(T result)
resolve in interface ResolvableFuture<T>public boolean fail(Throwable cause)
fail in interface AsyncFuture<T>fail in interface ResolvableFuture<T>public boolean cancel(boolean mayInterruptIfRunning)
public boolean cancel()
cancel in interface AsyncFuture<T>public AsyncFuture<T> bind(AsyncFuture<?> other)
bind in interface AsyncFuture<T>public AsyncFuture<T> onDone(FutureDone<? super T> done)
onDone in interface AsyncFuture<T>public AsyncFuture<T> onCancelled(FutureCancelled cancelled)
onCancelled in interface AsyncFuture<T>public AsyncFuture<T> onFinished(FutureFinished finishable)
onFinished in interface AsyncFuture<T>public AsyncFuture<T> onResolved(FutureResolved<? super T> resolved)
onResolved in interface AsyncFuture<T>public AsyncFuture<T> onFailed(FutureFailed failed)
onFailed in interface AsyncFuture<T>protected Runnable otherRunnable(AsyncFuture<?> other)
protected Runnable doneRunnable(FutureDone<? super T> done)
protected Runnable cancelledRunnable(FutureCancelled cancelled)
protected Runnable finishedRunnable(FutureFinished finishable)
protected Runnable resolvedRunnable(FutureResolved<? super T> resolved)
protected Runnable failedRunnable(FutureFailed failed)
public boolean isResolved()
isResolved in interface AsyncFuture<T>public boolean isFailed()
isFailed in interface AsyncFuture<T>public boolean isCancelled()
isCancelled in interface Future<T>public Throwable cause()
cause in interface AsyncFuture<T>public T get() throws InterruptedException, ExecutionException
get in interface Future<T>InterruptedExceptionExecutionExceptionpublic T getNow() throws ExecutionException
getNow in interface AsyncFuture<T>ExecutionExceptionpublic T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
get in interface Future<T>InterruptedExceptionExecutionExceptionTimeoutExceptionpublic <C> AsyncFuture<C> directTransform(Transform<? super T,? extends C> transform)
directTransform in interface AsyncFuture<T>public <C> AsyncFuture<C> lazyTransform(LazyTransform<? super T,C> transform)
lazyTransform in interface AsyncFuture<T>public AsyncFuture<T> catchFailed(Transform<Throwable,? extends T> transform)
catchFailed in interface AsyncFuture<T>public AsyncFuture<T> lazyCatchFailed(LazyTransform<Throwable,T> transform)
lazyCatchFailed in interface AsyncFuture<T>public AsyncFuture<T> catchCancelled(Transform<Void,? extends T> transform)
catchCancelled in interface AsyncFuture<T>public AsyncFuture<T> lazyCatchCancelled(LazyTransform<Void,T> transform)
lazyCatchCancelled in interface AsyncFuture<T>public static boolean isStateReady(int state)
Copyright © 2017. All rights reserved.