Package com.yahoo.processing.response
Class IncomingData.NullIncomingData<DATATYPE extends Data>
- java.lang.Object
-
- com.yahoo.processing.response.IncomingData.NullIncomingData<DATATYPE>
-
- All Implemented Interfaces:
IncomingData<DATATYPE>
- Enclosing interface:
- IncomingData<DATATYPE extends Data>
public static final class IncomingData.NullIncomingData<DATATYPE extends Data> extends java.lang.Object implements IncomingData<DATATYPE>
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.
- Throws an exception on any write method
This allows consumers to check for completion the same way whether or not the data list in question supports asynchronous addition of data, and without incurring unnecessary costs.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
IncomingData.NullIncomingData.ImmediateFuture<DATATYPE extends Data>
A future which is always done and incurs no synchronization.-
Nested classes/interfaces inherited from interface com.yahoo.processing.response.IncomingData
IncomingData.NullIncomingData<DATATYPE extends Data>
-
-
Constructor Summary
Constructors Constructor Description NullIncomingData(DataList<DATATYPE> owner)
-
Method Summary
All Methods Instance Methods Concrete 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)
Adds a new data listener to this - this is a no-op as new data can never be added to this implementation.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 truevoid
markComplete()
Do nothing as this is already completejava.lang.String
toString()
-
-
-
Method Detail
-
completed
public com.google.common.util.concurrent.ListenableFuture<DataList<DATATYPE>> completed()
Description copied from interface:IncomingData
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.
- Specified by:
completed
in interfaceIncomingData<DATATYPE extends Data>
-
getOwner
public DataList<DATATYPE> getOwner()
Description copied from interface:IncomingData
Returns the owner (target DataList) of this. Note that accessing the owner from the thread producing incoming data is generally *not* thread safe.- Specified by:
getOwner
in interfaceIncomingData<DATATYPE extends Data>
-
isComplete
public boolean isComplete()
Returns true- Specified by:
isComplete
in interfaceIncomingData<DATATYPE extends Data>
-
addLast
public void addLast(DATATYPE data)
Description copied from interface:IncomingData
Add new data and mark this as completed- Specified by:
addLast
in interfaceIncomingData<DATATYPE extends Data>
- Throws:
java.lang.IllegalStateException
- as this is read only
-
add
public void add(DATATYPE data)
Description copied from interface:IncomingData
Add new data without completing this- Specified by:
add
in interfaceIncomingData<DATATYPE extends Data>
- Throws:
java.lang.IllegalStateException
- as this is read only
-
addLast
public void addLast(java.util.List<DATATYPE> data)
Description copied from interface:IncomingData
Add new data and mark this as completed- Specified by:
addLast
in interfaceIncomingData<DATATYPE extends Data>
- Throws:
java.lang.IllegalStateException
- as this is read only
-
add
public void add(java.util.List<DATATYPE> data)
Description copied from interface:IncomingData
Add new data without completing this.- Specified by:
add
in interfaceIncomingData<DATATYPE extends Data>
- Throws:
java.lang.IllegalStateException
- as this is read only
-
markComplete
public void markComplete()
Do nothing as this is already complete- Specified by:
markComplete
in interfaceIncomingData<DATATYPE extends Data>
-
drain
public java.util.List<DATATYPE> drain()
Description copied from interface:IncomingData
Get and remove all the data currently available in this- Specified by:
drain
in interfaceIncomingData<DATATYPE extends Data>
-
addNewDataListener
public void addNewDataListener(java.lang.Runnable listener, java.util.concurrent.Executor executor)
Adds a new data listener to this - this is a no-op as new data can never be added to this implementation.- Specified by:
addNewDataListener
in interfaceIncomingData<DATATYPE extends Data>
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-