Class ArrayCompositeDisposable

  • All Implemented Interfaces:
    Disposable, java.io.Serializable

    public final class ArrayCompositeDisposable
    extends java.util.concurrent.atomic.AtomicReferenceArray<Disposable>
    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:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static long serialVersionUID  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void dispose()
      Dispose the resource, the operation should be idempotent.
      boolean isDisposed()
      Returns true if this resource has been disposed.
      Disposable replaceResource​(int index, Disposable resource)
      Replaces the resource at the specified index and returns the old resource.
      boolean setResource​(int index, Disposable resource)
      Sets the resource at the specified index and disposes the old resource.
      • Methods inherited from class java.util.concurrent.atomic.AtomicReferenceArray

        accumulateAndGet, compareAndExchange, compareAndExchangeAcquire, compareAndExchangeRelease, compareAndSet, get, getAcquire, getAndAccumulate, getAndSet, getAndUpdate, getOpaque, getPlain, lazySet, length, set, setOpaque, setPlain, setRelease, toString, updateAndGet, weakCompareAndSet, weakCompareAndSetAcquire, weakCompareAndSetPlain, weakCompareAndSetRelease, weakCompareAndSetVolatile
      • Methods inherited from class java.lang.Object

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

      • ArrayCompositeDisposable

        public ArrayCompositeDisposable​(int capacity)
    • Method Detail

      • setResource

        public boolean setResource​(int index,
                                   Disposable 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 Disposable replaceResource​(int index,
                                          Disposable 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