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
Modifier and TypeInterfaceDescriptionstatic final 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
Modifier and TypeMethodDescriptionvoid
Add new data without completing thisvoid
Add new data without completing this.void
Add new data and mark this as completedvoid
Add new data and mark this as completedvoid
addNewDataListener
(Runnable listener, Executor executor) Add a listener which will be invoked every time new data is added to this.Returns a future in which all the incoming data that will be produced in this is available.drain()
Get and remove all the data currently available in thisgetOwner()
Returns the owner (target DataList) of this.boolean
Returns whether this is completevoid
Mark this as completed and notify any listeners.
-
Method Details
-
getOwner
Returns the owner (target DataList) of this. Note that accessing the owner from the thread producing incoming data is generally *not* thread safe. -
completedFuture
CompletableFuture<DataList<DATATYPE>> completedFuture()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
Add new data and mark this as completed- Throws:
IllegalStateException
- if this is already complete or does not allow writes
-
add
Add new data without completing this- Throws:
IllegalStateException
- if this is already complete or does not allow writes
-
addLast
Add new data and mark this as completed- Throws:
IllegalStateException
- if this is already complete or does not allow writes
-
add
Add new data without completing this.- Throws:
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
Get and remove all the data currently available in this -
addNewDataListener
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
-