Class SequentialDisposable
java.lang.Object
java.util.concurrent.atomic.AtomicReference<Disposable>
io.reactivex.rxjava3.internal.disposables.SequentialDisposable
- All Implemented Interfaces:
Disposable, Serializable
A Disposable container that allows updating/replacing a Disposable
atomically and with respect of disposing the container itself.
The class extends AtomicReference directly so watch out for the API leak!
- Since:
- 2.0
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionConstructs an empty SequentialDisposable.SequentialDisposable(Disposable initial) Construct a SequentialDisposable with the initial Disposable provided. -
Method Summary
Modifier and TypeMethodDescriptionvoiddispose()Dispose the resource, the operation should be idempotent.booleanReturns true if this resource has been disposed.booleanreplace(Disposable next) Atomically: set the next disposable on this container but don't dispose the previous one (if any) or dispose next if the container has been disposed.booleanupdate(Disposable next) Atomically: set the next disposable on this container and dispose the previous one (if any) or dispose next if the container has been disposed.Methods inherited from class AtomicReference
accumulateAndGet, compareAndExchange, compareAndExchangeAcquire, compareAndExchangeRelease, compareAndSet, get, getAcquire, getAndAccumulate, getAndSet, getAndUpdate, getOpaque, getPlain, lazySet, set, setOpaque, setPlain, setRelease, toString, updateAndGet, weakCompareAndSet, weakCompareAndSetAcquire, weakCompareAndSetPlain, weakCompareAndSetRelease, weakCompareAndSetVolatile
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
-
Constructor Details
-
SequentialDisposable
public SequentialDisposable()Constructs an empty SequentialDisposable. -
SequentialDisposable
Construct a SequentialDisposable with the initial Disposable provided.- Parameters:
initial- the initial disposable, null allowed
-
-
Method Details
-
update
Atomically: set the next disposable on this container and dispose the previous one (if any) or dispose next if the container has been disposed.- Parameters:
next- the Disposable to set, may be null- Returns:
- true if the operation succeeded, false if the container has been disposed
- See Also:
-
replace
Atomically: set the next disposable on this container but don't dispose the previous one (if any) or dispose next if the container has been disposed.- Parameters:
next- the Disposable to set, may be null- Returns:
- true if the operation succeeded, false if the container has been disposed
- See Also:
-
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
-