public final class ArrayCompositeDisposable extends AtomicReferenceArray<Disposable> implements Disposable
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.
Constructor and Description |
---|
ArrayCompositeDisposable(int capacity) |
Modifier and Type | Method and 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.
|
accumulateAndGet, compareAndSet, get, getAndAccumulate, getAndSet, getAndUpdate, lazySet, length, set, toString, updateAndGet, weakCompareAndSet
public boolean setResource(int index, Disposable resource)
index
- the index of the resource to setresource
- the new resourcepublic Disposable replaceResource(int index, Disposable resource)
index
- the index of the resource to replaceresource
- the new resourcepublic void dispose()
Disposable
dispose
in interface Disposable
public boolean isDisposed()
Disposable
isDisposed
in interface Disposable
Copyright © 2019. All rights reserved.