Class OperatorPublish.PublishSubscriber<T>

    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) java.util.concurrent.atomic.AtomicReference<OperatorPublish.PublishSubscriber<T>> current
      Holds onto the current connected PublishSubscriber.
      (package private) boolean emitting
      Guarded by this.
      (package private) static OperatorPublish.InnerProducer[] EMPTY
      Indicates an empty array of inner producers.
      (package private) boolean missed
      Guarded by this.
      (package private) NotificationLite<T> nl
      The notification-lite factory.
      (package private) java.util.concurrent.atomic.AtomicReference<OperatorPublish.InnerProducer[]> producers
      Tracks the subscribed producers.
      (package private) java.util.Queue<java.lang.Object> queue
      Holds notifications from upstream.
      (package private) java.util.concurrent.atomic.AtomicBoolean shouldConnect
      Atomically changed from false to true by connect to make sure the connection is only performed by one thread.
      (package private) java.lang.Object terminalEvent
      Contains either an onCompleted or an onError token from upstream.
      (package private) static OperatorPublish.InnerProducer[] TERMINATED
      Indicates a terminated PublishSubscriber.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) boolean add​(OperatorPublish.InnerProducer<T> producer)
      Atomically try adding a new InnerProducer to this Subscriber or return false if this Subscriber was terminated.
      (package private) boolean checkTerminated​(java.lang.Object term, boolean empty)
      Perform termination actions in case the source has terminated in some way and the queue has also become empty.
      (package private) void dispatch()
      The common serialization point of events arriving from upstream and child-subscribers requesting more.
      (package private) void init()
      Should be called after the constructor finished to setup nulling-out the current reference.
      void onCompleted()
      Notifies the Observer that the Observable has finished sending push-based notifications.
      void onError​(java.lang.Throwable e)
      Notifies the Observer that the Observable has experienced an error condition.
      void onNext​(T t)
      Provides the Observer with a new item to observe.
      void onStart()
      This method is invoked when the Subscriber and Observable have been connected but the Observable has not yet begun to emit items or send notifications to the Subscriber.
      (package private) void remove​(OperatorPublish.InnerProducer<T> producer)
      Atomically removes the given producer from the producers array.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • queue

        final java.util.Queue<java.lang.Object> queue
        Holds notifications from upstream.
      • terminalEvent

        volatile java.lang.Object terminalEvent
        Contains either an onCompleted or an onError token from upstream.
      • shouldConnect

        final java.util.concurrent.atomic.AtomicBoolean shouldConnect
        Atomically changed from false to true by connect to make sure the connection is only performed by one thread.
      • emitting

        boolean emitting
        Guarded by this.
      • missed

        boolean missed
        Guarded by this.
    • Method Detail

      • init

        void init()
        Should be called after the constructor finished to setup nulling-out the current reference.
      • onStart

        public void onStart()
        Description copied from class: Subscriber
        This method is invoked when the Subscriber and Observable have been connected but the Observable has not yet begun to emit items or send notifications to the Subscriber. Override this method to add any useful initialization to your subscription, for instance to initiate backpressure.
        Overrides:
        onStart in class Subscriber<T>
      • add

        boolean add​(OperatorPublish.InnerProducer<T> producer)
        Atomically try adding a new InnerProducer to this Subscriber or return false if this Subscriber was terminated.
        Parameters:
        producer - the producer to add
        Returns:
        true if succeeded, false otherwise
      • remove

        void remove​(OperatorPublish.InnerProducer<T> producer)
        Atomically removes the given producer from the producers array.
        Parameters:
        producer - the producer to remove
      • checkTerminated

        boolean checkTerminated​(java.lang.Object term,
                                boolean empty)
        Perform termination actions in case the source has terminated in some way and the queue has also become empty.
        Parameters:
        term - the terminal event (a NotificationLite.error or completed)
        empty - set to true if the queue is empty
        Returns:
        true if there is indeed a terminal condition
      • dispatch

        void dispatch()
        The common serialization point of events arriving from upstream and child-subscribers requesting more.