summaryrefslogtreecommitdiffstats
path: root/processing
diff options
context:
space:
mode:
Diffstat (limited to 'processing')
-rw-r--r--processing/src/main/java/com/yahoo/processing/response/DataList.java21
-rw-r--r--processing/src/main/java/com/yahoo/processing/response/IncomingData.java22
2 files changed, 26 insertions, 17 deletions
diff --git a/processing/src/main/java/com/yahoo/processing/response/DataList.java b/processing/src/main/java/com/yahoo/processing/response/DataList.java
index 911cb6f70e6..1f762ab8d58 100644
--- a/processing/src/main/java/com/yahoo/processing/response/DataList.java
+++ b/processing/src/main/java/com/yahoo/processing/response/DataList.java
@@ -28,9 +28,9 @@ public interface DataList<DATATYPE extends Data> extends Data {
* @param data the data to add to this
* @return the input data instance, for chaining
*/
- public DATATYPE add(DATATYPE data);
+ DATATYPE add(DATATYPE data);
- public DATATYPE get(int index);
+ DATATYPE get(int index);
/**
* Returns the content of this as a List.
@@ -38,7 +38,7 @@ public interface DataList<DATATYPE extends Data> extends Data {
* If the returned list is editable and this is frozen, the only allowed operation is to add new items
* to the end of the list.
*/
- public List<DATATYPE> asList();
+ List<DATATYPE> asList();
/**
* Returns the buffer of incoming/future data to this list.
@@ -49,7 +49,7 @@ public interface DataList<DATATYPE extends Data> extends Data {
* such lists responds to <i>read</i> calls to IncomingData as expected and without
* incurring any synchronization, and throws an exception on <i>write</i> calls.
*/
- public IncomingData<DATATYPE> incoming();
+ IncomingData<DATATYPE> incoming();
/**
* Returns a future in which all incoming data in this has become available.
@@ -73,13 +73,22 @@ public interface DataList<DATATYPE extends Data> extends Data {
* Making this call on a list which does not support future data always returns immediately and
* causes no memory synchronization cost.
*/
- public ListenableFuture<DataList<DATATYPE>> complete();
+ ListenableFuture<DataList<DATATYPE>> complete();
/**
* Adds a listener which is invoked every time data is added to this list.
* The listener is always invoked on the same thread which is adding the data,
* and hence it can modify this list freely without synchronization.
*/
- public void addDataListener(Runnable runnable);
+ void addDataListener(Runnable runnable);
+
+ /**
+ * Notify this list that is will never be accessed again, neither for read nor write.
+ * Implementations can override this as an optimization to release any data held in the list
+ * for garbage collection.
+ *
+ * This default implementation does nothing.
+ */
+ default void close() {};
}
diff --git a/processing/src/main/java/com/yahoo/processing/response/IncomingData.java b/processing/src/main/java/com/yahoo/processing/response/IncomingData.java
index 7034b2c2a02..b8cdf8683bc 100644
--- a/processing/src/main/java/com/yahoo/processing/response/IncomingData.java
+++ b/processing/src/main/java/com/yahoo/processing/response/IncomingData.java
@@ -22,7 +22,7 @@ public interface IncomingData<DATATYPE extends Data> {
* Note that accessing the owner from the thread producing incoming data
* is generally *not* thread safe.
*/
- public DataList<DATATYPE> getOwner();
+ DataList<DATATYPE> getOwner();
/**
* Returns a future in which all the incoming data that will be produced in this is available.
@@ -35,57 +35,57 @@ public interface IncomingData<DATATYPE extends Data> {
* <p>
* This return the list owning this for convenience.
*/
- public abstract ListenableFuture<DataList<DATATYPE>> completed();
+ ListenableFuture<DataList<DATATYPE>> completed();
/**
* Returns whether this is complete
*/
- public boolean isComplete();
+ boolean isComplete();
/**
* Add new data and mark this as completed
*
* @throws IllegalStateException if this is already complete or does not allow writes
*/
- public void addLast(DATATYPE data);
+ void addLast(DATATYPE data);
/**
* Add new data without completing this
*
* @throws IllegalStateException if this is already complete or does not allow writes
*/
- public void add(DATATYPE data);
+ void add(DATATYPE data);
/**
* Add new data and mark this as completed
*
* @throws IllegalStateException if this is already complete or does not allow writes
*/
- public void addLast(List<DATATYPE> data);
+ void addLast(List<DATATYPE> data);
/**
* Add new data without completing this.
*
* @throws IllegalStateException if this is already complete or does not allow writes
*/
- public void add(List<DATATYPE> data);
+ void add(List<DATATYPE> data);
/**
* Mark this as completed and notify any listeners. If this is already complete this method does nothing.
*/
- public void markComplete();
+ void markComplete();
/**
* Get and remove all the data currently available in this
*/
- public List<DATATYPE> drain();
+ List<DATATYPE> drain();
/**
* 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
*/
- public void addNewDataListener(Runnable listener, Executor executor);
+ void addNewDataListener(Runnable listener, Executor executor);
/**
* Creates a null implementation of this which is empty and complete at creation:
@@ -98,7 +98,7 @@ public interface IncomingData<DATATYPE extends Data> {
* 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.
*/
- public static final class NullIncomingData<DATATYPE extends Data> implements IncomingData<DATATYPE> {
+ final class NullIncomingData<DATATYPE extends Data> implements IncomingData<DATATYPE> {
private DataList<DATATYPE> owner;
private final ImmediateFuture<DATATYPE> completionFuture;