Class AsyncSubscriber<T>

  • All Implemented Interfaces:
    java.lang.Runnable, Subscriber<T>

    public abstract class AsyncSubscriber<T>
    extends java.lang.Object
    implements Subscriber<T>, java.lang.Runnable
    AsyncSubscriber is an implementation of Reactive Streams `Subscriber`, it runs asynchronously (on an Executor), requests one element at a time, and invokes a user-defined method to process each element. NOTE: The code below uses a lot of try-catches to show the reader where exceptions can be expected, and where they are forbidden.
    • Field Detail

      • done

        private boolean done
      • executor

        private final java.util.concurrent.Executor executor
      • inboundSignals

        private final java.util.concurrent.ConcurrentLinkedQueue<AsyncSubscriber.Signal> inboundSignals
      • on

        private final java.util.concurrent.atomic.AtomicBoolean on
    • Constructor Detail

      • AsyncSubscriber

        protected AsyncSubscriber​(java.util.concurrent.Executor executor)