public class CallFuture<T> extends Object implements java.util.concurrent.Future<T>, Callback<T>
Constructor and Description |
---|
CallFuture()
Creates a CallFuture.
|
CallFuture(Callback<T> chainedCallback)
Creates a CallFuture with a chained Callback which will be invoked
when this CallFuture's Callback methods are invoked.
|
Modifier and Type | Method and Description |
---|---|
void |
await()
Waits for the CallFuture to complete without returning the result.
|
void |
await(long timeout,
java.util.concurrent.TimeUnit unit)
Waits for the CallFuture to complete without returning the result.
|
boolean |
cancel(boolean mayInterruptIfRunning) |
T |
get() |
T |
get(long timeout,
java.util.concurrent.TimeUnit unit) |
Throwable |
getError()
Gets the error that was thrown during RPC execution.
|
T |
getResult()
Gets the value of the RPC result without blocking.
|
void |
handleError(Throwable error)
Sets an error thrown during RPC execution, and unblocks all threads waiting
on
get() or get(long, TimeUnit) . |
void |
handleResult(T result)
Sets the RPC response, and unblocks all threads waiting on
get()
or get(long, TimeUnit) . |
boolean |
isCancelled() |
boolean |
isDone() |
public void handleResult(T result)
get()
or get(long, TimeUnit)
.handleResult
in interface Callback<T>
result
- the RPC result to set.public void handleError(Throwable error)
get()
or get(long, TimeUnit)
.handleError
in interface Callback<T>
error
- the RPC error to set.public T getResult()
get()
or get(long, TimeUnit)
is usually
preferred because these methods block until the result is available or
an error occurs.public Throwable getError()
get()
or get(long, TimeUnit)
should be called
first because these methods block until the RPC has completed.public boolean cancel(boolean mayInterruptIfRunning)
cancel
in interface java.util.concurrent.Future<T>
public boolean isCancelled()
isCancelled
in interface java.util.concurrent.Future<T>
public T get() throws InterruptedException, java.util.concurrent.ExecutionException
get
in interface java.util.concurrent.Future<T>
InterruptedException
java.util.concurrent.ExecutionException
public T get(long timeout, java.util.concurrent.TimeUnit unit) throws InterruptedException, java.util.concurrent.ExecutionException, java.util.concurrent.TimeoutException
get
in interface java.util.concurrent.Future<T>
InterruptedException
java.util.concurrent.ExecutionException
java.util.concurrent.TimeoutException
public void await() throws InterruptedException
InterruptedException
- if interrupted.public void await(long timeout, java.util.concurrent.TimeUnit unit) throws InterruptedException, java.util.concurrent.TimeoutException
timeout
- the maximum time to wait.unit
- the time unit of the timeout argument.InterruptedException
- if interrupted.java.util.concurrent.TimeoutException
- if the wait timed out.public boolean isDone()
isDone
in interface java.util.concurrent.Future<T>
Copyright © 2009–2018 The Apache Software Foundation. All rights reserved.