public class FutureData<T> extends Object
| Modifier and Type | Field and Description |
|---|---|
protected BlockingQueue<Object> |
block |
protected T |
data |
protected Throwable |
interruptCause |
protected org.cliffc.high_scale_lib.NonBlockingHashSet<FutureResponse<T>> |
listeners |
| Constructor and Description |
|---|
FutureData() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
doNotify() |
void |
interuptCause(Throwable cause) |
protected void |
notifyListeners() |
FutureData<T> |
onData(FutureResponse<T> response)
Adds an event listener that is notified when data is received
|
void |
received(T data)
Invoked when a response is received and this future data is now available for use/processing
|
T |
sync()
Forces the client to wait until a response is received before returning
|
static <A extends BaseDataSiftResult> |
wrap(A obj)
Wraps any object in a
FutureData instance
Intended use is to enable any object obtained without a future to be passed to API methods. |
protected org.cliffc.high_scale_lib.NonBlockingHashSet<FutureResponse<T>> listeners
protected T data
protected Throwable interruptCause
protected final BlockingQueue<Object> block
public static <A extends BaseDataSiftResult> FutureData<A> wrap(A obj)
FutureData instance
Intended use is to enable any object obtained without a future to be passed to API methods.
This allows API methods to accept FutureData objects and alleviates the need for a user to add
many callbacks and instead just pass futures around as if they were already obtained values.
Note that any listeners added will be immediately invoked/notified, seeing as the result they would
await has already been obtainedA - the type of the objectobj - the object to wrappublic void received(T data)
data - the data received or an object wrapping said datapublic FutureData<T> onData(FutureResponse<T> response)
response - the future which should listen for a responseprotected void notifyListeners()
protected void doNotify()
public T sync()
public void interuptCause(Throwable cause)
Copyright © 2015. All Rights Reserved.