Class AsyncSubscription

java.lang.Object
java.lang.Number
java.util.concurrent.atomic.AtomicLong
io.reactivex.rxjava3.internal.subscriptions.AsyncSubscription
All Implemented Interfaces:
Disposable, Serializable, org.reactivestreams.Subscription

public final class AsyncSubscription extends AtomicLong implements org.reactivestreams.Subscription, Disposable
A subscription implementation that arbitrates exactly one other Subscription and can hold a single disposable resource.

All methods are thread-safe.

See Also:
  • Field Details

  • Constructor Details

    • AsyncSubscription

      public AsyncSubscription()
    • AsyncSubscription

      public AsyncSubscription(Disposable resource)
  • Method Details

    • request

      public void request(long n)
      Specified by:
      request in interface org.reactivestreams.Subscription
    • cancel

      public void cancel()
      Specified by:
      cancel in interface org.reactivestreams.Subscription
    • dispose

      public void dispose()
      Description copied from interface: Disposable
      Dispose the resource, the operation should be idempotent.
      Specified by:
      dispose in interface Disposable
    • isDisposed

      public boolean isDisposed()
      Description copied from interface: Disposable
      Returns true if this resource has been disposed.
      Specified by:
      isDisposed in interface Disposable
      Returns:
      true if this resource has been disposed
    • setResource

      public boolean setResource(Disposable r)
      Sets a new resource and disposes the currently held resource.
      Parameters:
      r - the new resource to set
      Returns:
      false if this AsyncSubscription has been cancelled/disposed
      See Also:
    • replaceResource

      public boolean replaceResource(Disposable r)
      Replaces the currently held resource with the given new one without disposing the old.
      Parameters:
      r - the new resource to set
      Returns:
      false if this AsyncSubscription has been cancelled/disposed
    • setSubscription

      public void setSubscription(org.reactivestreams.Subscription s)
      Sets the given subscription if there isn't any subscription held.
      Parameters:
      s - the first and only subscription to set