Package com.yahoo.processing.response
Interface IncomingData<DATATYPE extends Data>
-
- All Known Implementing Classes:
DefaultIncomingData
,IncomingData.NullIncomingData
public interface IncomingData<DATATYPE extends Data>
A data list own once instance of this which can be used to provide data asynchronously to the list, and consume, wait for or be notified upon the arrival of such data.- Author:
- bratseth
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
IncomingData.NullIncomingData<DATATYPE extends Data>
Creates a null implementation of this which is empty and complete at creation: Provides immediate return without incurring any memory synchronization for any read method.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
add(DATATYPE data)
Add new data without completing thisvoid
add(java.util.List<DATATYPE> data)
Add new data without completing this.void
addLast(DATATYPE data)
Add new data and mark this as completedvoid
addLast(java.util.List<DATATYPE> data)
Add new data and mark this as completedvoid
addNewDataListener(java.lang.Runnable listener, java.util.concurrent.Executor executor)
Add a listener which will be invoked every time new data is added to this.com.google.common.util.concurrent.ListenableFuture<DataList<DATATYPE>>
completed()
Returns a future in which all the incoming data that will be produced in this is available.java.util.List<DATATYPE>
drain()
Get and remove all the data currently available in thisDataList<DATATYPE>
getOwner()
Returns the owner (target DataList) of this.boolean
isComplete()
Returns whether this is completevoid
markComplete()
Mark this as completed and notify any listeners.
-
-
-
Method Detail
-
getOwner
DataList<DATATYPE> getOwner()
Returns the owner (target DataList) of this. Note that accessing the owner from the thread producing incoming data is generally *not* thread safe.
-
completed
com.google.common.util.concurrent.ListenableFuture<DataList<DATATYPE>> completed()
Returns a future in which all the incoming data that will be produced in this is available. Listeners on this are invoked on the thread producing the incoming data (or a thread spawned from it), which in general is separate from the thread using the data list. Hence, listeners on this even cannot in general assume that they may modify the data list or the request.The data is not
drained
into the owner of this by this method. That must be done by the thread using the data list.This return the list owning this for convenience.
-
isComplete
boolean isComplete()
Returns whether this is complete
-
addLast
void addLast(DATATYPE data)
Add new data and mark this as completed- Throws:
java.lang.IllegalStateException
- if this is already complete or does not allow writes
-
add
void add(DATATYPE data)
Add new data without completing this- Throws:
java.lang.IllegalStateException
- if this is already complete or does not allow writes
-
addLast
void addLast(java.util.List<DATATYPE> data)
Add new data and mark this as completed- Throws:
java.lang.IllegalStateException
- if this is already complete or does not allow writes
-
add
void add(java.util.List<DATATYPE> data)
Add new data without completing this.- Throws:
java.lang.IllegalStateException
- if this is already complete or does not allow writes
-
markComplete
void markComplete()
Mark this as completed and notify any listeners. If this is already complete this method does nothing.
-
drain
java.util.List<DATATYPE> drain()
Get and remove all the data currently available in this
-
addNewDataListener
void addNewDataListener(java.lang.Runnable listener, java.util.concurrent.Executor executor)
Add a listener which will be invoked every time new data is added to this. This listener may be invoked at any time in any thread, any thread synchronization is left to the listener itself
-
-