Class ArrayCompositeSubscription
- java.lang.Object
-
- java.util.concurrent.atomic.AtomicReferenceArray<org.reactivestreams.Subscription>
-
- io.reactivex.rxjava3.internal.subscriptions.ArrayCompositeSubscription
-
- All Implemented Interfaces:
Disposable,java.io.Serializable
public final class ArrayCompositeSubscription extends java.util.concurrent.atomic.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:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private static longserialVersionUID
-
Constructor Summary
Constructors Constructor Description ArrayCompositeSubscription(int capacity)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddispose()Dispose the resource, the operation should be idempotent.booleanisDisposed()Returns true if this resource has been disposed.org.reactivestreams.SubscriptionreplaceResource(int index, org.reactivestreams.Subscription resource)Replaces the resource at the specified index and returns the old resource.booleansetResource(int index, org.reactivestreams.Subscription 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, org.reactivestreams.Subscription 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 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 replaceresource- the new resource- Returns:
- the old resource, can be null
-
dispose
public void dispose()
Description copied from interface:DisposableDispose the resource, the operation should be idempotent.- Specified by:
disposein interfaceDisposable
-
isDisposed
public boolean isDisposed()
Description copied from interface:DisposableReturns true if this resource has been disposed.- Specified by:
isDisposedin interfaceDisposable- Returns:
- true if this resource has been disposed
-
-