Class ArrayCompositeDisposable
- java.lang.Object
-
- java.util.concurrent.atomic.AtomicReferenceArray<Disposable>
-
- io.reactivex.rxjava3.internal.disposables.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
-
Constructor Summary
Constructors Constructor Description ArrayCompositeDisposable(int capacity)
-
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
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
-
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 setresource
- 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 replaceresource
- 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 interfaceDisposable
-
isDisposed
public boolean isDisposed()
Description copied from interface:Disposable
Returns true if this resource has been disposed.- Specified by:
isDisposed
in interfaceDisposable
- Returns:
- true if this resource has been disposed
-
-