Class RxRingBuffer

  • All Implemented Interfaces:
    Subscription


    public class RxRingBuffer
    extends Object
    implements Subscription
    This assumes Spsc or Spmc usage. This means only a single producer calling the on* methods. This is the Rx contract of an Observer. Concurrent invocations of on* methods will not be thread-safe.
    • Field Detail

      • terminalState

        public volatile Object terminalState
        We store the terminal state separately so it doesn't count against the size. We don't just +1 the size since some of the queues require sizes that are a power of 2. This is a subjective thing ... wanting to keep the size (ie 1024) the actual number of onNext that can be sent rather than something like 1023 onNext + 1 terminal event. It also simplifies checking that we have received only 1 terminal event, as we don't need to peek at the last item or retain a boolean flag.
      • SIZE

        public static final int SIZE
    • Method Detail

      • getSpscInstance

        public static RxRingBuffer getSpscInstance()
      • getSpmcInstance

        public static RxRingBuffer getSpmcInstance()
      • release

        public void release()
      • unsubscribe

        public void unsubscribe()
        Description copied from interface: Subscription
        Stops the receipt of notifications on the Subscriber that was registered when this Subscription was received.

        This allows unregistering an Subscriber before it has finished receiving all events (i.e. before onCompleted is called).

      • onCompleted

        public void onCompleted()
      • available

        public int available()
      • capacity

        public int capacity()
      • count

        public int count()
      • isEmpty

        public boolean isEmpty()
      • isCompleted

        public boolean isCompleted(Object o)
      • isError

        public boolean isError(Object o)
      • isUnsubscribed

        public boolean isUnsubscribed()
        Description copied from interface: Subscription
        Indicates whether this Subscription is currently unsubscribed.
        Specified by:
        isUnsubscribed in interface  Subscription
        Returns:
        true if this Subscription is currently unsubscribed, false otherwise