public abstract class TriggerFuture<T> extends Object implements Future<T>
A Future> wrapper that executes an abstract method with the result at some point after the data becomes available. A "best effort" is made to ensure execution, but it may be left untriggered until the end of a request.
Notification will happen ONCE:
Use the AsyncCacheFilter for normal requests. For situations where a filter is not appropriate (ie, the remote api) be sure to call PendingFutures.completeAllPendingFutures() manually.
Note that if you are using this with Objectify, you probably want to use ObjectifyFilter.complete() rather than PendingFutures or AsyncCacheFilter static methods.
Modifier and Type | Field and Description |
---|---|
protected Future<T> |
raw
Wrap the raw Future>
|
Constructor and Description |
---|
TriggerFuture(Future<T> raw)
Wrap a normal Future>
|
Modifier and Type | Method and Description |
---|---|
boolean |
cancel(boolean mayInterruptIfRunning) |
T |
get() |
T |
get(long timeout,
TimeUnit unit) |
boolean |
isCancelled() |
boolean |
isDone()
This version also checks to see if we are done and we still need to call the trigger.
|
protected abstract void |
trigger()
This method will be called ONCE upon completion of the future, successful or not.
|
protected abstract void trigger()
public boolean cancel(boolean mayInterruptIfRunning)
public boolean isCancelled()
isCancelled
in interface Future<T>
public boolean isDone()
isDone
in interface Future<T>
Future.isDone()
public T get() throws InterruptedException, ExecutionException
get
in interface Future<T>
InterruptedException
ExecutionException
public T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
get
in interface Future<T>
InterruptedException
ExecutionException
TimeoutException
Copyright © 2016. All rights reserved.