Top Description Fields Constructors Methods
io.reactivex.internal.disposables

public final Class SequentialDisposable

extends AtomicReference<Disposable>
implements Disposable
Class Inheritance
All Implemented Interfaces
io.reactivex.disposables.Disposable
Imports
java.util.concurrent.atomic.AtomicReference, io.reactivex.disposables.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

Field Summary

Modifier and TypeField and Description
private static final long

Constructor Summary

AccessConstructor and Description
public
SequentialDisposable()

Constructs an empty SequentialDisposable.

public
SequentialDisposable(Disposable
the initial disposable, null allowed
initial
)

Construct a SequentialDisposable with the initial Disposable provided.

Method Summary

Modifier and TypeMethod and Description
public void
dispose()

Implements io.reactivex.disposables.Disposable.dispose.

Dispose the resource, the operation should be idempotent.
public boolean
isDisposed()

Implements io.reactivex.disposables.Disposable.isDisposed.

Returns true if this resource has been disposed.
public boolean

Returns:

true if the operation succeeded, false if the container has been disposed
replace
(Disposable
the Disposable to set, may be null
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.

public boolean

Returns:

true if the operation succeeded, false if the container has been disposed
update
(Disposable
the Disposable to set, may be null
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.

Inherited from java.util.concurrent.atomic.AtomicReference:
accumulateAndGetcompareAndExchangecompareAndExchangeAcquirecompareAndExchangeReleasecompareAndSetgetgetAcquiregetAndAccumulategetAndSetgetAndUpdategetOpaquegetPlainlazySetsetsetOpaquesetPlainsetReleasetoStringupdateAndGetweakCompareAndSetweakCompareAndSetAcquireweakCompareAndSetPlainweakCompareAndSetReleaseweakCompareAndSetVolatile

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.util.concurrent.atomic.AtomicReference.serialVersionUID.

Constructor Detail

SequentialDisposableback to summary
public SequentialDisposable()

Constructs an empty SequentialDisposable.

SequentialDisposableback to summary
public SequentialDisposable(Disposable initial)

Construct a SequentialDisposable with the initial Disposable provided.

Parameters
initial:Disposable

the initial disposable, null allowed

Method Detail

disposeback to summary
public void dispose()

Implements io.reactivex.disposables.Disposable.dispose.

Doc from io.reactivex.disposables.Disposable.dispose.

Dispose the resource, the operation should be idempotent.

Annotations
@Override
isDisposedback to summary
public boolean isDisposed()

Implements io.reactivex.disposables.Disposable.isDisposed.

Doc from io.reactivex.disposables.Disposable.isDisposed.

Returns true if this resource has been disposed.

Returns:boolean

true if this resource has been disposed

Annotations
@Override
replaceback to summary
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:Disposable

the Disposable to set, may be null

Returns:boolean

true if the operation succeeded, false if the container has been disposed

See Also
update(Disposable)
updateback to summary
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:Disposable

the Disposable to set, may be null

Returns:boolean

true if the operation succeeded, false if the container has been disposed

See Also
replace(Disposable)