public interface DataList<DATATYPE extends Data> extends Data
A data list can be frozen even though its child data items are not. When a datalist is frozen the only permissible write operation is to add new items to the end of the list.
Content in a frozen list may be returned to the requesting client immediately by the underlying engine, even if the Response owning the list is not returned yet.
Modifier and Type | Method and Description |
---|---|
DATATYPE |
add(DATATYPE data)
Adds a child data item to this.
|
void |
addDataListener(Runnable runnable)
Adds a listener which is invoked every time data is added to this list.
|
List<DATATYPE> |
asList()
Returns the content of this as a List.
|
com.google.common.util.concurrent.ListenableFuture<DataList<DATATYPE>> |
complete()
Returns a future in which all incoming data in this has become available.
|
DATATYPE |
get(int index) |
IncomingData<DATATYPE> |
incoming()
Returns the buffer of incoming/future data to this list.
|
DATATYPE add(DATATYPE data)
data
- the data to add to thisDATATYPE get(int index)
List<DATATYPE> asList()
IncomingData<DATATYPE> incoming()
Some list instances do not support late incoming data, such lists responds to read calls to IncomingData as expected and without incurring any synchronization, and throws an exception on write calls.
com.google.common.util.concurrent.ListenableFuture<DataList<DATATYPE>> complete()
get(int)
on this future will block (if necessary) until all incoming data has arrived,
transfer that data from the incoming buffer into this list and invoke any listeners on this event
on the calling thread.
Note that if no thread calls completed().get(), this future will never occur.
Any data list consumer who wishes to make sure it sees the complete data for this list
must call dataList.complete().get()
before consuming this list.
If a guaranteed non-blocking call to this method is desired, register a listener on the future where all
data is available for draining (that is, on dataList.incoming().completed()
)
and resume by calling this method from the listener.
Making this call on a list which does not support future data always returns immediately and causes no memory synchronization cost.
void addDataListener(Runnable runnable)
Copyright © 2018. All rights reserved.