Module methanol

Class FlowSupport


  • public class FlowSupport
    extends java.lang.Object
    Helpers for implementing reactive streams subscriptions and the like.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.util.concurrent.Flow.Subscription NOOP_SUBSCRIPTION
      A subscription that does nothing.
      static java.util.concurrent.Executor SYNC_EXECUTOR
      An executor that executes the runnable in the calling thread.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> java.util.concurrent.Flow.Publisher<T> emptyPublisher()  
      static long getAndAddDemand​(java.lang.Object owner, java.lang.invoke.VarHandle demand, long n)
      Adds the given count to demand, making sure it doesn't exceed Long.MAX_VALUE.
      static void onDroppedException​(java.lang.Throwable exception)  
      static int prefetch()
      Returns the prefetch property or a default of 8.
      static int prefetchThreshold()
      Returns the prefetch threshold according to the prefetch factor property or a default of 8 / 2.
      static void reject​(java.util.concurrent.Flow.Subscriber<?> subscriber, java.lang.Throwable cause)  
      static void rejectMulticast​(java.util.concurrent.Flow.Subscriber<?> subscriber)  
      static long subtractAndGetDemand​(java.lang.Object owner, java.lang.invoke.VarHandle demand, long n)
      Subtracts given count from demand.
      • Methods inherited from class java.lang.Object

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

      • NOOP_SUBSCRIPTION

        public static final java.util.concurrent.Flow.Subscription NOOP_SUBSCRIPTION
        A subscription that does nothing.
      • SYNC_EXECUTOR

        public static final java.util.concurrent.Executor SYNC_EXECUTOR
        An executor that executes the runnable in the calling thread.
    • Method Detail

      • prefetch

        public static int prefetch()
        Returns the prefetch property or a default of 8.
      • prefetchThreshold

        public static int prefetchThreshold()
        Returns the prefetch threshold according to the prefetch factor property or a default of 8 / 2.
      • getAndAddDemand

        public static long getAndAddDemand​(java.lang.Object owner,
                                           java.lang.invoke.VarHandle demand,
                                           long n)
        Adds the given count to demand, making sure it doesn't exceed Long.MAX_VALUE.
      • subtractAndGetDemand

        public static long subtractAndGetDemand​(java.lang.Object owner,
                                                java.lang.invoke.VarHandle demand,
                                                long n)
        Subtracts given count from demand. Caller must ensure the result won't be negative.
      • emptyPublisher

        public static <T> java.util.concurrent.Flow.Publisher<T> emptyPublisher()
      • rejectMulticast

        public static void rejectMulticast​(java.util.concurrent.Flow.Subscriber<?> subscriber)
      • reject

        public static void reject​(java.util.concurrent.Flow.Subscriber<?> subscriber,
                                  java.lang.Throwable cause)
      • onDroppedException

        public static void onDroppedException​(java.lang.Throwable exception)