Call to the dispose method is/should be idempotent.
| Modifier and Type | Class and Description |
|---|---|
| public static interface | Disposable.Composite
A container of |
| public static interface | Disposable.Swap
A |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public default boolean | Returns: true when there's a guarantee the resource or task is disposed.Optionally return true when the resource or task is disposed. |
| dispose | back to summary |
|---|---|
| public void dispose() Cancel or dispose the underlying task or resource. Implementations are required to make this method idempotent. | |
| isDisposed | back to summary |
|---|---|
| public default boolean isDisposed() Optionally return true when the resource or task is disposed. Implementations are not required to track disposition and as such may never return true even when disposed. However, they MUST only return true when there's a guarantee the resource or task is disposed.
| |
Disposable that is itself Disposable. Accumulate
disposables and dispose them all in one go by using dispose(). Using
the add(Disposable) methods give ownership to the container, which is now
responsible for disposing them. You can however retake ownership of individual
elements by keeping a reference and using remove(Disposable), which puts
the responsibility of disposing said elements back in your hands. Note that once
disposed, the container cannot be reused and you will need a new Composite.
| Modifier and Type | Method and Description |
|---|---|
| public boolean | Returns: true if the disposable could be added, false otherwise.the d)Disposable to add.Add a |
| public default boolean | Returns: true if the operation was successful, false if the container has been disposedthe collection of Disposables ds)Adds the given collection of Disposables to the container or disposes them all if the container has been disposed. |
| public void | dispose()
Redeclares reactor. disposed, clear it and then
dispose all the previously contained Disposables.
|
| public boolean | Returns: true if the container has been disposed, false otherwise.Redeclares as abstract: reactor. |
| public boolean | Returns: true if the disposable was successfully deleted, false otherwise.the d)Disposable to remove.Delete the |
| public int | Returns: the number of currently held DisposablesReturns the number of currently held Disposables. |
| add | back to summary |
|---|---|
| public boolean add(Disposable d) Add a
| |
| addAll | back to summary |
|---|---|
| public default boolean addAll(Collection<? extends Disposable> ds) Adds the given collection of Disposables to the container or disposes them all if the container has been disposed. Implementation Note The default implementation is not atomic, meaning that if the container is
disposed while the content of the collection is added, first elements might be
effectively added. Stronger consistency is enforced by composites created via
| |
| dispose | back to summary |
|---|---|
| public void dispose() Redeclares reactor. Atomically mark the container as
| |
| isDisposed | back to summary |
|---|---|
| public boolean isDisposed() Redeclares as abstract: reactor. Indicates if the container has already been disposed. Note that if that is the case, attempts to add new disposable to it via
| |
| remove | back to summary |
|---|---|
| public boolean remove(Disposable d) Delete the
It becomes the responsibility of the caller to dispose the value themselves,
which they can do by a simple call to
| |
| size | back to summary |
|---|---|
| public int size() Returns the number of currently held Disposables.
| |
Disposable container that allows updating/replacing its inner Disposable
atomically and with respect of disposing the container itself.
| Modifier and Type | Method and Description |
|---|---|
| public boolean | Returns: true if the operation succeeded, false if the container has been disposedthe next)Disposable to set, may be nullAtomically set the next |
| public boolean | Returns: true if the operation succeeded, false if the container has been disposedthe next)Disposable to set, may be nullAtomically set the next |
| replace | back to summary |
|---|---|
| public boolean replace(Disposable next) Atomically set the next
| |
| update | back to summary |
|---|---|
| public boolean update(Disposable next) Atomically set the next
| |