Class ArrayCompositeSubscription

java.lang.Object
java.util.concurrent.atomic.AtomicReferenceArray<org.reactivestreams.Subscription>
io.reactivex.rxjava3.internal.subscriptions.ArrayCompositeSubscription
All Implemented Interfaces:
Disposable, Serializable

public final class ArrayCompositeSubscription extends AtomicReferenceArray<org.reactivestreams.Subscription> implements Disposable
A composite disposable with a fixed number of slots.

Note that since the implementation leaks the methods of AtomicReferenceArray, one must be careful to only call setResource, replaceResource and dispose on it. All other methods may lead to undefined behavior and should be used by internal means only.

See Also:
  • Field Details

  • Constructor Details

    • ArrayCompositeSubscription

      public ArrayCompositeSubscription(int capacity)
  • Method Details

    • setResource

      public boolean setResource(int index, org.reactivestreams.Subscription resource)
      Sets the resource at the specified index and disposes the old resource.
      Parameters:
      index - the index of the resource to set
      resource - the new resource
      Returns:
      true if the resource has ben set, false if the composite has been disposed
    • replaceResource

      public org.reactivestreams.Subscription replaceResource(int index, org.reactivestreams.Subscription resource)
      Replaces the resource at the specified index and returns the old resource.
      Parameters:
      index - the index of the resource to replace
      resource - the new resource
      Returns:
      the old resource, can be null
    • 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