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 final class 
    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 Type
    Method
    Description
    void
    add(DATATYPE data)
    Add new data without completing this
    void
    add(List<DATATYPE> data)
    Add new data without completing this.
    void
    Add new data and mark this as completed
    void
    Add new data and mark this as completed
    void
    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.
    Get and remove all the data currently available in this
    Returns the owner (target DataList) of this.
    boolean
    Returns whether this is complete
    void
    Mark this as completed and notify any listeners.
  • Method Details

    • 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.
    • 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

      void addLast(DATATYPE data)
      Add new data and mark this as completed
      Throws:
      IllegalStateException - if this is already complete or does not allow writes
    • add

      void add(DATATYPE data)
      Add new data without completing this
      Throws:
      IllegalStateException - if this is already complete or does not allow writes
    • addLast

      void addLast(List<DATATYPE> data)
      Add new data and mark this as completed
      Throws:
      IllegalStateException - if this is already complete or does not allow writes
    • add

      void add(List<DATATYPE> data)
      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

      List<DATATYPE> drain()
      Get and remove all the data currently available in this
    • addNewDataListener

      void addNewDataListener(Runnable listener, 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