Class SequentialDisposable
- java.lang.Object
-
- java.util.concurrent.atomic.AtomicReference<Disposable>
-
- io.reactivex.rxjava3.internal.disposables.SequentialDisposable
-
- All Implemented Interfaces:
Disposable,java.io.Serializable
public final class SequentialDisposable extends java.util.concurrent.atomic.AtomicReference<Disposable> implements Disposable
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:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private static longserialVersionUID
-
Constructor Summary
Constructors Constructor Description SequentialDisposable()Constructs an empty SequentialDisposable.SequentialDisposable(Disposable initial)Construct a SequentialDisposable with the initial Disposable provided.
-
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.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 java.util.concurrent.atomic.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 Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SequentialDisposable
public SequentialDisposable()
Constructs an empty SequentialDisposable.
-
SequentialDisposable
public SequentialDisposable(Disposable initial)
Construct a SequentialDisposable with the initial Disposable provided.- Parameters:
initial- the initial disposable, null allowed
-
-
Method Detail
-
update
public boolean update(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.- 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(Disposable)
-
replace
public boolean replace(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.- Parameters:
next- the Disposable to set, may be null- Returns:
- true if the operation succeeded, false if the container has been disposed
- See Also:
update(Disposable)
-
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
-
-