Class SingleThreadedBufferingSubscriber<T>

  • Type Parameters:
    T - The type
    All Implemented Interfaces:
    Completable, Emitter<T>, org.reactivestreams.Subscriber<T>
    Direct Known Subclasses:
    SingleThreadedBufferingProcessor

    public abstract class SingleThreadedBufferingSubscriber<T>
    extends java.lang.Object
    implements org.reactivestreams.Subscriber<T>, Emitter<T>
    A Subscriber designed to be used by a single thread that buffers incoming data for the purposes of managing back pressure.
    Since:
    1.0
    • Field Detail

      • upstreamBuffer

        protected final java.util.Queue<T> upstreamBuffer
      • upstreamDemand

        protected long upstreamDemand
      • upstreamSubscription

        protected org.reactivestreams.Subscription upstreamSubscription
    • Constructor Detail

      • SingleThreadedBufferingSubscriber

        public SingleThreadedBufferingSubscriber()
    • Method Detail

      • onSubscribe

        public final void onSubscribe​(org.reactivestreams.Subscription subscription)
        Specified by:
        onSubscribe in interface org.reactivestreams.Subscriber<T>
      • onComplete

        public final void onComplete()
        Description copied from interface: Completable
        * Successful terminal state. To be called when the operation is complete.
        Specified by:
        onComplete in interface Completable
        Specified by:
        onComplete in interface org.reactivestreams.Subscriber<T>
        See Also:
        Subscriber.onComplete()
      • onNext

        public final void onNext​(T message)
        Description copied from interface: Emitter
        Data notification sent by the Publisher in response to requests to Subscription.request(long).
        Specified by:
        onNext in interface Emitter<T>
        Specified by:
        onNext in interface org.reactivestreams.Subscriber<T>
        Parameters:
        message - the element signaled
      • onError

        public final void onError​(java.lang.Throwable t)
        Description copied from interface: Emitter
        Failed terminal state.

        No further events will be sent even if Subscription.request(long) is invoked again.

        Specified by:
        onError in interface Emitter<T>
        Specified by:
        onError in interface org.reactivestreams.Subscriber<T>
        Parameters:
        t - the throwable signaled
      • doOnSubscribe

        protected abstract void doOnSubscribe​(org.reactivestreams.Subscription subscription)
        Implement Subscriber.onSubscribe(Subscription).
        Parameters:
        subscription - The subscription
      • doOnNext

        protected abstract void doOnNext​(T message)
        Implement Subscriber.onNext(Object).
        Parameters:
        message - The message
      • doOnError

        protected abstract void doOnError​(java.lang.Throwable t)
        Implement Subscriber.onError(Throwable).
        Parameters:
        t - The throwable
      • doOnComplete

        protected abstract void doOnComplete()
        Implement Subscriber.onComplete().
      • provideDownstreamSubscription

        protected void provideDownstreamSubscription​(org.reactivestreams.Subscriber subscriber)
        Parameters:
        subscriber - The subscriber
      • newDownstreamSubscription

        protected org.reactivestreams.Subscription newDownstreamSubscription()
        Returns:
        The subscription