T - the resource tpyepublic final class ArrayCompositeResource<T> extends java.util.concurrent.atomic.AtomicReferenceArray<java.lang.Object> 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 |
|---|
ArrayCompositeResource(int capacity,
Consumer<? super T> disposer) |
| Modifier and Type | Method and Description |
|---|---|
void |
dispose()
Dispose the resource, the operation should be idempotent.
|
boolean |
isDisposed() |
T |
replaceResource(int index,
T resource)
Replaces the resource at the specified index and returns the old resource.
|
boolean |
setResource(int index,
T resource)
Sets the resource at the specified index and disposes the old resource.
|
public boolean setResource(int index,
T resource)
index - resource - public T replaceResource(int index, T resource)
index - resource - public void dispose()
Disposabledispose in interface Disposablepublic boolean isDisposed()