Module methanol

Class FlowSupport

java.lang.Object
com.github.mizosoft.methanol.internal.flow.FlowSupport

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

    • NOOP_SUBSCRIPTION

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

      public static final Executor SYNC_EXECUTOR
      An executor that executes the runnable in the calling thread.
  • Method Details

    • illegalRequest

      public static IllegalArgumentException illegalRequest()
      Returns an IllegalArgumentException to signal if the subscriber requests a non-positive number of items.
    • 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(Object owner, VarHandle demand, long n)
      Adds the given count to demand, making sure it doesn't exceed Long.MAX_VALUE.
    • subtractAndGetDemand

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

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

      public static void rejectMulticast(Flow.Subscriber<?> subscriber)
    • onDroppedException

      public static void onDroppedException(Throwable exception)