Class OperatorMerge.MergeSubscriber<T>

    • Field Detail

      • delayErrors

        final boolean delayErrors
      • maxConcurrent

        final int maxConcurrent
      • queue

        volatile java.util.Queue<java.lang.Object> queue
      • subscriptions

        volatile CompositeSubscription subscriptions
        Tracks the active subscriptions to sources.
      • errors

        volatile java.util.concurrent.ConcurrentLinkedQueue<java.lang.Throwable> errors
        Due to the emission loop, we need to store errors somewhere if !delayErrors.
      • done

        volatile boolean done
      • emitting

        boolean emitting
        Guarded by this.
      • missed

        boolean missed
        Guarded by this.
      • innerGuard

        final java.lang.Object innerGuard
      • uniqueId

        long uniqueId
        Used to generate unique InnerSubscriber IDs. Modified from onNext only.
      • lastId

        long lastId
        Which was the last InnerSubscriber that emitted? Accessed if emitting == true.
      • lastIndex

        int lastIndex
        What was its index in the innerSubscribers array? Accessed if emitting == true.
      • scalarEmissionLimit

        final int scalarEmissionLimit
      • scalarEmissionCount

        int scalarEmissionCount
    • Constructor Detail

      • MergeSubscriber

        public MergeSubscriber​(Subscriber<? super T> child,
                               boolean delayErrors,
                               int maxConcurrent)
    • Method Detail

      • getOrCreateErrorQueue

        java.util.Queue<java.lang.Throwable> getOrCreateErrorQueue()
      • emitEmpty

        void emitEmpty()
      • reportError

        private void reportError()
      • onError

        public void onError​(java.lang.Throwable e)
        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:
        e - the exception encountered by the Observable
      • tryEmit

        void tryEmit​(OperatorMerge.InnerSubscriber<T> subscriber,
                     T value)
        Tries to emit the value directly to the child if no concurrent emission is happening at the moment.

        Since the scalar-value queue optimization applies to both the main source and the inner subscribers, we handle things in a shared manner.

        Parameters:
        subscriber -
        value -
      • requestMore

        public void requestMore​(long n)
      • tryEmit

        void tryEmit​(T value)
        Tries to emit the value directly to the child if no concurrent emission is happening at the moment.

        Since the scalar-value queue optimization applies to both the main source and the inner subscribers, we handle things in a shared manner.

        Parameters:
        subscriber -
        value -
      • queueScalar

        protected void queueScalar​(T value)
      • emitScalar

        protected void emitScalar​(T value,
                                  long r)
      • emit

        void emit()
      • emitLoop

        void emitLoop()
        The standard emission loop serializing events and requests.
      • checkTerminate

        boolean checkTerminate()
        Check if the operator reached some terminal state: child unsubscribed, an error was reported and we don't delay errors.
        Returns:
        true if the child unsubscribed or there are errors available and merge doesn't delay errors.