Future<Void>, CompletionListenerpublic class CompletionListenerFuture extends Object implements CompletionListener, Future<Void>
For example:
//create a completion future to use to wait for loadAll
CompletionListenerFuture future = new CompletionListenerFuture();
//load the values for the set of keys, replacing those that may already exist
//in the cache
cache.loadAll(keys, true, future);
//wait for the cache to load the keys
future.get();
A CompletionListenerFuture may only be used once. Attempts to use an instance
multiple times, as part of multiple asynchronous calls will result in an
IllegalStateException being raised.
| Constructor | Description |
|---|---|
CompletionListenerFuture() |
Constructs a CompletionListenerFuture.
|
| Modifier and Type | Method | Description |
|---|---|---|
boolean |
cancel(boolean b) |
Cancelling is not supported, always throws exception.
|
Void |
get() |
Waits if necessary for the operation to complete.
|
Void |
get(long timeout,
TimeUnit unit) |
Waits if necessary for at most the given time for the operation
to complete.
|
boolean |
isCancelled() |
Cancelling is not supported, always returns false
|
boolean |
isDone() |
|
void |
onCompletion() |
Notifies the application that the operation completed successfully.
|
void |
onException(Exception e) |
Notifies the application that the operation failed.
|
public CompletionListenerFuture()
public void onCompletion()
throws IllegalStateException
onCompletion in interface CompletionListenerIllegalStateException - if the instance is used more than oncepublic void onException(Exception e) throws IllegalStateException
onException in interface CompletionListenere - the Exception that occurredIllegalStateException - if the instance is used more than oncepublic boolean cancel(boolean b)
cancel in interface Future<Void>UnsupportedOperationException - thrown alwayspublic boolean isCancelled()
isCancelled in interface Future<Void>public Void get() throws InterruptedException, ExecutionException
null.get in interface Future<Void>nullExecutionException - if the computation threw an
exception. This wraps the exception received by (Exception)InterruptedException - if the current thread was interrupted
while waitingpublic Void get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
null.get in interface Future<Void>timeout - the maximum time to waitunit - the time unit of the timeout argumentnullExecutionException - if the computation threw an
exception. This wraps the exception received by (Exception)InterruptedException - if the current thread was interrupted
while waitingTimeoutException - if the wait timed outCopyright © 2017. All rights reserved.