Class SerialSubscription

  • All Implemented Interfaces:
    Subscription

    public final class SerialSubscription
    extends java.lang.Object
    implements Subscription
    Represents a subscription whose underlying subscription can be swapped for another subscription which causes the previous underlying subscription to be unsubscribed.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      (package private) static class  SerialSubscription.State  
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) java.util.concurrent.atomic.AtomicReference<SerialSubscription.State> state  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Subscription get()
      Retrieves the current Subscription that is being represented by this SerialSubscription.
      boolean isUnsubscribed()
      Indicates whether this Subscription is currently unsubscribed.
      void set​(Subscription s)
      Swaps out the old Subscription for the specified Subscription.
      void unsubscribe()
      Stops the receipt of notifications on the Subscriber that was registered when this Subscription was received.
      • Methods inherited from class java.lang.Object

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

      • SerialSubscription

        public SerialSubscription()
    • Method Detail

      • 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
      • 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).

        Specified by:
        unsubscribe in interface Subscription
      • set

        public void set​(Subscription s)
        Swaps out the old Subscription for the specified Subscription.
        Parameters:
        s - the new Subscription to swap in
        Throws:
        java.lang.IllegalArgumentException - if s is null
      • get

        public Subscription get()
        Retrieves the current Subscription that is being represented by this SerialSubscription.
        Returns:
        the current Subscription that is being represented by this SerialSubscription