Class DeferredScalarSubscriber<T,​R>

    • Field Detail

      • actual

        protected final Subscriber<? super R> actual
        The downstream subscriber.
      • hasValue

        protected boolean hasValue
        Indicates there is a value available in value.
      • value

        protected R value
        The holder of the single value.
      • state

        final java.util.concurrent.atomic.AtomicInteger state
        The state, see the constants below.
      • NO_REQUEST_NO_VALUE

        static final int NO_REQUEST_NO_VALUE
        Initial state.
        See Also:
        Constant Field Values
      • HAS_REQUEST_NO_VALUE

        static final int HAS_REQUEST_NO_VALUE
        Request came first.
        See Also:
        Constant Field Values
      • NO_REQUEST_HAS_VALUE

        static final int NO_REQUEST_HAS_VALUE
        Value came first.
        See Also:
        Constant Field Values
      • HAS_REQUEST_HAS_VALUE

        static final int HAS_REQUEST_HAS_VALUE
        Value will be emitted.
        See Also:
        Constant Field Values
    • Constructor Detail

      • DeferredScalarSubscriber

        public DeferredScalarSubscriber​(Subscriber<? super R> actual)
    • Method Detail

      • onError

        public void onError​(java.lang.Throwable ex)
        Description copied from interface: Observer
        Notifies the Observer that the Observable has experienced an error condition.

        If the Observable calls this method, it will not thereafter call Observer.onNext(T) or Observer.onCompleted().

        Parameters:
        ex - the exception encountered by the Observable
      • complete

        protected final void complete()
        Signals onCompleted() to the downstream subscriber.
      • complete

        protected final void complete​(R value)
        Atomically switches to the terminal state and emits the value if there is a request for it or stores it for retrieval by downstreamRequest(long).
        Parameters:
        value - the value to complete with
      • downstreamRequest

        final void downstreamRequest​(long n)
      • setProducer

        public final void setProducer​(Producer p)
        Description copied from class: Subscriber
        If other subscriber is set (by calling constructor Subscriber(Subscriber) or Subscriber(Subscriber, boolean)) then this method calls setProducer on the other subscriber. If the other subscriber is not set and no requests have been made to this subscriber then p.request(Long.MAX_VALUE) is called. If the other subscriber is not set and some requests have been made to this subscriber then p.request(n) is called where n is the accumulated requests to this subscriber.
        Overrides:
        setProducer in class Subscriber<T>
        Parameters:
        p - producer to be used by this subscriber or the other subscriber (or recursively its other subscriber) to make requests from
      • subscribeTo

        public final void subscribeTo​(Observable<? extends T> source)
        Links up with the downstream Subscriber (cancellation, backpressure) and subscribes to the source Observable.
        Parameters:
        source - the source Observable
      • setupDownstream

        final void setupDownstream()