V
- The type for the set value.public class FutureCallback<V> extends Object implements Future<V>, Callback<V>
Callback
and Future
interfaces. Used to
convert a Callback
into a Future
for returning to callers.Modifier and Type | Field and Description |
---|---|
static Class<?> |
CLASS
The class for the
FutureCallback . |
Constructor and Description |
---|
FutureCallback()
Create a new FutureCallback.
|
Modifier and Type | Method and Description |
---|---|
void |
callback(V result)
Called when the MongoDB operation has completed with the result of the
operation.
|
boolean |
cancel(boolean mayInterruptIfRunning) |
void |
exception(Throwable thrown)
Called when the operation fails due to an exception.
|
V |
get() |
V |
get(long timeout,
TimeUnit unit) |
boolean |
isCancelled() |
boolean |
isDone() |
public static final Class<?> CLASS
FutureCallback
.public void callback(V result)
Sets the value for the future and triggers any pending get()
to
return.
callback
in interface Callback<V>
result
- The result of the operation.Callback.callback(V)
public boolean cancel(boolean mayInterruptIfRunning)
If not cancelled and the callback has not completed then cancels the
future, triggers the return of any pending get()
and returns
true. Otherwise returns false. This does not stop the related MongoDB
invocation.
cancel
in interface Future<V>
Future.cancel(boolean)
public void exception(Throwable thrown)
Sets the exception for the future and triggers any pending get()
to throw a ExecutionException
.
exception
in interface Callback<V>
thrown
- The thrown exception.Callback.exception(java.lang.Throwable)
public V get() throws InterruptedException, ExecutionException
Returns the value set via the Callback
.
get
in interface Future<V>
InterruptedException
ExecutionException
Future.get()
public V get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
Returns the value set via the Callback
.
get
in interface Future<V>
InterruptedException
ExecutionException
TimeoutException
Future.get(long, TimeUnit)
public boolean isCancelled()
Returns true if cancel(boolean)
has been called.
isCancelled
in interface Future<V>
Future.isCancelled()
public boolean isDone()
isDone
in interface Future<V>
Future.isDone()
Copyright © 2011-2013 Allanbank Consulting, Inc.. All Rights Reserved.