public class AsyncCompletionStage<V> extends FiberAsync<V,java.util.concurrent.ExecutionException>
CompletableFutures into fiber-blocking operations.| Modifier and Type | Method and Description |
|---|---|
static <V> V |
get(java.util.concurrent.CompletionStage<V> future)
Blocks the current strand (either fiber or thread) until the given future completes, and returns its result.
|
static <V> V |
get(java.util.concurrent.CompletionStage<V> future,
long timeout,
java.util.concurrent.TimeUnit unit)
Blocks the current strand (either fiber or thread) until the given future completes - but no longer than the given timeout - and returns its result.
|
static <V> V |
get(java.util.concurrent.CompletionStage<V> future,
Timeout timeout)
Blocks the current strand (either fiber or thread) until the given future completes - but no longer than the given timeout - and returns its result.
|
protected void |
requestAsync()
A user of this class must override this method to start the asynchronous operation and register the callback.
|
protected V |
requestSync()
Called if
FiberAsync.run() is not being executed in a fiber. |
protected java.util.concurrent.ExecutionException |
wrapException(java.lang.Throwable t)
Takes the exception generated by the async operation and possibly wraps it in an exception
that will be thrown by the
run method. |
asyncCompleted, asyncFailed, getResult, interrupted, isCompleted, prepark, requestSync, run, run, run, runBlocking, runBlocking, runBlocking, waitForRegistrationpublic static <V> V get(java.util.concurrent.CompletionStage<V> future)
throws java.util.concurrent.ExecutionException,
java.lang.InterruptedException,
SuspendExecution
future - the futurejava.util.concurrent.ExecutionException - if the future's computation threw an exceptionjava.lang.InterruptedException - if the current thread was interrupted while waitingSuspendExecutionpublic static <V> V get(java.util.concurrent.CompletionStage<V> future,
long timeout,
java.util.concurrent.TimeUnit unit)
throws java.util.concurrent.ExecutionException,
java.lang.InterruptedException,
SuspendExecution,
java.util.concurrent.TimeoutException
future - the futuretimeout - the maximum duration to wait for the future's resultunit - the timeout's time unitjava.util.concurrent.ExecutionException - if the future's computation threw an exceptionjava.util.concurrent.TimeoutException - if the timeout expired before the future completedjava.lang.InterruptedException - if the current thread was interrupted while waitingSuspendExecutionpublic static <V> V get(java.util.concurrent.CompletionStage<V> future,
Timeout timeout)
throws java.util.concurrent.ExecutionException,
java.lang.InterruptedException,
SuspendExecution,
java.util.concurrent.TimeoutException
future - the futuretimeout - the method will not block for longer than the amount remaining in the Timeoutjava.util.concurrent.ExecutionException - if the future's computation threw an exceptionjava.util.concurrent.TimeoutException - if the timeout expired before the future completedjava.lang.InterruptedException - if the current thread was interrupted while waitingSuspendExecutionprotected void requestAsync()
FiberAsyncThreadLocals.requestAsync in class FiberAsync<V,java.util.concurrent.ExecutionException>protected java.util.concurrent.ExecutionException wrapException(java.lang.Throwable t)
FiberAsyncrun method.wrapException in class FiberAsync<V,java.util.concurrent.ExecutionException>protected V requestSync() throws java.lang.InterruptedException, java.util.concurrent.ExecutionException
FiberAsyncFiberAsync.run() is not being executed in a fiber. Should perform the operation synchronously and return its result.
The default implementation of this method throws an `IllegalThreadStateException`.requestSync in class FiberAsync<V,java.util.concurrent.ExecutionException>java.lang.InterruptedExceptionjava.util.concurrent.ExecutionException