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