Class DrainUtils


  • public class DrainUtils
    extends java.lang.Object
    Copy from Project Reactor.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected static long COMPLETED_MASK
      Indicates the source completed and the value field is ready to be emitted.
      protected static long REQUESTED_MASK  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> void postComplete​(org.reactivestreams.Subscriber<? super T> downstream, java.util.Queue<T> queue, java.util.concurrent.atomic.AtomicLong requested, java.util.function.BooleanSupplier isCancelled)
      Tries draining the queue if the source just completed.
      static <T> boolean postCompleteRequest​(long n, org.reactivestreams.Subscriber<? super T> downstream, java.util.Queue<T> queue, java.util.concurrent.atomic.AtomicLong requested, java.util.function.BooleanSupplier isCancelled)
      Perform a potential post-completion request accounting.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • COMPLETED_MASK

        protected static final long COMPLETED_MASK
        Indicates the source completed and the value field is ready to be emitted.

        The AtomicLong (this) holds the requested amount in bits 0..62 so there is room for one signal bit. This also means the standard request accounting helper method doesn't work.

        See Also:
        Constant Field Values
    • Method Detail

      • postCompleteRequest

        public static <T> boolean postCompleteRequest​(long n,
                                                      org.reactivestreams.Subscriber<? super T> downstream,
                                                      java.util.Queue<T> queue,
                                                      java.util.concurrent.atomic.AtomicLong requested,
                                                      java.util.function.BooleanSupplier isCancelled)
        Perform a potential post-completion request accounting.
        Type Parameters:
        T - the output value type
        Parameters:
        n - the requested amount
        downstream - the downstream consumer
        queue - the queue holding the available values
        requested - the requested atomic long
        isCancelled - callback to detect cancellation
        Returns:
        true if the state indicates a completion state.
      • postComplete

        public static <T> void postComplete​(org.reactivestreams.Subscriber<? super T> downstream,
                                            java.util.Queue<T> queue,
                                            java.util.concurrent.atomic.AtomicLong requested,
                                            java.util.function.BooleanSupplier isCancelled)
        Tries draining the queue if the source just completed.
        Type Parameters:
        T - the output value type
        Parameters:
        downstream - the downstream consumer
        queue - the queue holding available values
        requested - the atomic long keeping track of requests
        isCancelled - callback to detect cancellation