Package io.servicetalk.concurrent.api
Interface CompositeCloseable
- All Superinterfaces:
AsyncCloseable
,AutoCloseable
,GracefulAutoCloseable
-
Method Summary
Modifier and TypeMethodDescription<T extends AsyncCloseable>
Tappend
(T closeable) Appends the passedAsyncCloseable
with thisCompositeCloseable
such that when thisCompositeCloseable
is closed, all of the previously registeredAsyncCloseable
s are closed too.appendAll
(AsyncCloseable... asyncCloseables) Appends all the passedAsyncCloseable
s with thisCompositeCloseable
such that when thisCompositeCloseable
is closed, all of theseAsyncCloseable
s are closed too.appendAll
(Iterable<? extends AsyncCloseable> asyncCloseables) Appends all the passedAsyncCloseable
s with thisCompositeCloseable
such that when thisCompositeCloseable
is closed, all of theseAsyncCloseable
s are closed too.void
close()
Closes all containedAsyncCloseable
s and awaits termination of all of them.Closes all containedAsyncCloseable
s.<T extends AsyncCloseable>
Tmerge
(T closeable) Merges the passedAsyncCloseable
with thisCompositeCloseable
such that when thisCompositeCloseable
is closed, all of the previously registeredAsyncCloseable
s are closed too.mergeAll
(AsyncCloseable... asyncCloseables) Merges all the passedAsyncCloseable
s with thisCompositeCloseable
such that when thisCompositeCloseable
is closed, all of theseAsyncCloseable
s are closed too.mergeAll
(Iterable<? extends AsyncCloseable> asyncCloseables) Merges all the passedAsyncCloseable
s with thisCompositeCloseable
such that when thisCompositeCloseable
is closed, all of theseAsyncCloseable
s are closed too.<T extends AsyncCloseable>
Tprepend
(T closeable) Prepends the passedAsyncCloseable
with thisCompositeCloseable
such that when thisCompositeCloseable
is closed, all of the previously registeredAsyncCloseable
s are closed too.prependAll
(AsyncCloseable... asyncCloseables) Prepends all the passedAsyncCloseable
s with thisCompositeCloseable
such that when thisCompositeCloseable
is closed, all of theseAsyncCloseable
s are closed too.prependAll
(Iterable<? extends AsyncCloseable> asyncCloseables) Prepends all the passedAsyncCloseable
s with thisCompositeCloseable
such that when thisCompositeCloseable
is closed, all of theseAsyncCloseable
s are closed too.Methods inherited from interface io.servicetalk.concurrent.api.AsyncCloseable
closeAsyncGracefully
Methods inherited from interface io.servicetalk.concurrent.GracefulAutoCloseable
closeGracefully
-
Method Details
-
merge
Merges the passedAsyncCloseable
with thisCompositeCloseable
such that when thisCompositeCloseable
is closed, all of the previously registeredAsyncCloseable
s are closed too. This method subscribes to the passed inAsyncCloseable
and the current composite set at the same time. If an order of closure is required, then useappend(AsyncCloseable)
orprepend(AsyncCloseable)
.- Type Parameters:
T
- the type ofAsyncCloseable
to be merged- Parameters:
closeable
-AsyncCloseable
that is closed when thisCompositeCloseable
is closed.- Returns:
T
-
mergeAll
Merges all the passedAsyncCloseable
s with thisCompositeCloseable
such that when thisCompositeCloseable
is closed, all of theseAsyncCloseable
s are closed too. This method subscribes to all passed inAsyncCloseable
s and the current composite set at the same time. If an order of closure is required, then useappendAll(AsyncCloseable...)
orprependAll(AsyncCloseable...)
.- Parameters:
asyncCloseables
- AllAsyncCloseable
s that are closed when thisCompositeCloseable
is closed.- Returns:
this
.
-
mergeAll
Merges all the passedAsyncCloseable
s with thisCompositeCloseable
such that when thisCompositeCloseable
is closed, all of theseAsyncCloseable
s are closed too. This method subscribes to all passed inAsyncCloseable
s and the current composite set at the same time. If an order of closure is required, then useappendAll(AsyncCloseable...)
orprependAll(AsyncCloseable...)
.- Parameters:
asyncCloseables
- AllAsyncCloseable
s that are closed when thisCompositeCloseable
is closed.- Returns:
this
.
-
append
Appends the passedAsyncCloseable
with thisCompositeCloseable
such that when thisCompositeCloseable
is closed, all of the previously registeredAsyncCloseable
s are closed too. This method subscribes to the passed inAsyncCloseable
and the current composite set in order. If an order of closure is not required, then usemerge(AsyncCloseable)
.- Type Parameters:
T
- the type ofAsyncCloseable
to be appended- Parameters:
closeable
-AsyncCloseable
that is closed when thisCompositeCloseable
is closed.- Returns:
T
.
-
appendAll
Appends all the passedAsyncCloseable
s with thisCompositeCloseable
such that when thisCompositeCloseable
is closed, all of theseAsyncCloseable
s are closed too. This method subscribes to all passed inAsyncCloseable
s and the current composite set in the order they are passed to this method. If an order of closure is not required, then usemergeAll(AsyncCloseable...)
.- Parameters:
asyncCloseables
- AllAsyncCloseable
s that are closed when thisCompositeCloseable
is closed.- Returns:
this
.
-
appendAll
Appends all the passedAsyncCloseable
s with thisCompositeCloseable
such that when thisCompositeCloseable
is closed, all of theseAsyncCloseable
s are closed too. This method subscribes to all passed inAsyncCloseable
s and the current composite set in the order they are passed to this method. If an order of closure is not required, then usemergeAll(AsyncCloseable...)
.- Parameters:
asyncCloseables
- AllAsyncCloseable
s that are closed when thisCompositeCloseable
is closed.- Returns:
this
.
-
prepend
Prepends the passedAsyncCloseable
with thisCompositeCloseable
such that when thisCompositeCloseable
is closed, all of the previously registeredAsyncCloseable
s are closed too. This method subscribes to the passed inAsyncCloseable
and the current composite set in reverse order. If an order of closure is not required, then usemerge(AsyncCloseable)
.- Type Parameters:
T
- the type ofAsyncCloseable
to be prepended- Parameters:
closeable
-AsyncCloseable
that is closed when thisCompositeCloseable
is closed.- Returns:
T
.
-
prependAll
Prepends all the passedAsyncCloseable
s with thisCompositeCloseable
such that when thisCompositeCloseable
is closed, all of theseAsyncCloseable
s are closed too. This method subscribes to all passed inAsyncCloseable
s and the current composite set in the reverse order they are passed to this method. If an order of closure is not required, then usemergeAll(AsyncCloseable...)
.- Parameters:
asyncCloseables
- AllAsyncCloseable
s that are closed when thisCompositeCloseable
is closed.- Returns:
this
.
-
prependAll
Prepends all the passedAsyncCloseable
s with thisCompositeCloseable
such that when thisCompositeCloseable
is closed, all of theseAsyncCloseable
s are closed too. This method subscribes to all passed inAsyncCloseable
s and the current composite set in the reverse order they are passed to this method. If an order of closure is not required, then usemergeAll(AsyncCloseable...)
.- Parameters:
asyncCloseables
- AllAsyncCloseable
s that are closed when thisCompositeCloseable
is closed.- Returns:
this
.
-
closeAsync
Completable closeAsync()Closes all containedAsyncCloseable
s. If any of the containedAsyncCloseable
s terminated with a failure, the returnedCompletable
terminates with a failure only after all the containedAsyncCloseable
s have terminated.- Specified by:
closeAsync
in interfaceAsyncCloseable
- Returns:
- the
Completable
that is notified once the close is complete.
-
close
Closes all containedAsyncCloseable
s and awaits termination of all of them. If any of the containedAsyncCloseable
s terminated with a failure, this method terminates with anException
only after all the containedAsyncCloseable
s have terminated.- Specified by:
close
in interfaceAutoCloseable
- Throws:
Exception
- If any of the containedAsyncCloseable
s terminate with a failure.
-