public final class SerialDisposable extends Object implements Disposable
Constructor and Description |
---|
SerialDisposable()
Constructs an empty SerialDisposable.
|
SerialDisposable(Disposable initialDisposable)
Constructs a SerialDisposable with the given initial Disposable instance.
|
Modifier and Type | Method and Description |
---|---|
void |
dispose()
Dispose the resource, the operation should be idempotent.
|
Disposable |
get()
Returns the currently contained Disposable or null if this container is empty.
|
boolean |
isDisposed()
Returns true if this resource has been disposed.
|
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.
|
boolean |
set(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.
|
public SerialDisposable()
public SerialDisposable(@Nullable Disposable initialDisposable)
initialDisposable
- the initial Disposable instance to use, null allowedpublic boolean set(@Nullable Disposable next)
next
- the Disposable to set, may be nullreplace(Disposable)
public boolean replace(@Nullable Disposable next)
next
- the Disposable to set, may be nullset(Disposable)
@Nullable public Disposable get()
public void dispose()
Disposable
dispose
in interface Disposable
public boolean isDisposed()
Disposable
isDisposed
in interface Disposable