Interface WriteDemandEstimator

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      long estimateRequestN​(long writeBufferCapacityInBytes)
      Given the current capacity of the write buffer, supply how many items to request next from the associated PublisherSource.Subscription.
      void onItemWrite​(java.lang.Object written, long writeBufferCapacityBeforeWrite, long writeBufferCapacityAfterWrite)
      Callback whenever an item is written on the connection.
    • Method Detail

      • onItemWrite

        void onItemWrite​(java.lang.Object written,
                         long writeBufferCapacityBeforeWrite,
                         long writeBufferCapacityAfterWrite)
        Callback whenever an item is written on the connection.

        Write buffer capacity may not correctly reflect size of the object written. Hence capacity before may not necessarily be more than capacity after write.

        Parameters:
        written - Item that was written.
        writeBufferCapacityBeforeWrite - Capacity of the write buffer before this item was written.
        writeBufferCapacityAfterWrite - Capacity of the write buffer after this item was written.
      • estimateRequestN

        long estimateRequestN​(long writeBufferCapacityInBytes)
        Given the current capacity of the write buffer, supply how many items to request next from the associated PublisherSource.Subscription.

        This method is invoked every time there could be a need to request more items from the write Publisher. This means that the supplied writeBufferCapacityInBytes may include the capacity for which we have already requested the write Publisher.

        Parameters:
        writeBufferCapacityInBytes - Current write buffer capacity. This will always be non-negative and will be 0 if buffer is full.
        Returns:
        Number of items to request next from the associated PublisherSource.Subscription. Implementation may assume that whatever is returned here is sent as-is to the associated PublisherSource.Subscription.