Package io.servicetalk.concurrent.api
Interface CompositeCloseable
-
- All Superinterfaces:
AsyncCloseable
,java.lang.AutoCloseable
,GracefulAutoCloseable
public interface CompositeCloseable extends AsyncCloseable, GracefulAutoCloseable
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <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.CompositeCloseable
appendAll(AsyncCloseable... asyncCloseables)
Appends all the passedAsyncCloseable
s with thisCompositeCloseable
such that when thisCompositeCloseable
is closed, all of theseAsyncCloseable
s are closed too.CompositeCloseable
appendAll(java.lang.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.Completable
closeAsync()
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.CompositeCloseable
mergeAll(AsyncCloseable... asyncCloseables)
Merges all the passedAsyncCloseable
s with thisCompositeCloseable
such that when thisCompositeCloseable
is closed, all of theseAsyncCloseable
s are closed too.CompositeCloseable
mergeAll(java.lang.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.CompositeCloseable
prependAll(AsyncCloseable... asyncCloseables)
Prepends all the passedAsyncCloseable
s with thisCompositeCloseable
such that when thisCompositeCloseable
is closed, all of theseAsyncCloseable
s are closed too.CompositeCloseable
prependAll(java.lang.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 Detail
-
merge
<T extends AsyncCloseable> T merge(T closeable)
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
CompositeCloseable mergeAll(AsyncCloseable... asyncCloseables)
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
CompositeCloseable mergeAll(java.lang.Iterable<? extends AsyncCloseable> asyncCloseables)
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
<T extends AsyncCloseable> T append(T closeable)
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
CompositeCloseable appendAll(AsyncCloseable... asyncCloseables)
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
CompositeCloseable appendAll(java.lang.Iterable<? extends AsyncCloseable> asyncCloseables)
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
<T extends AsyncCloseable> T prepend(T closeable)
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
CompositeCloseable prependAll(AsyncCloseable... asyncCloseables)
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
CompositeCloseable prependAll(java.lang.Iterable<? extends AsyncCloseable> asyncCloseables)
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
void close() throws java.lang.Exception
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 interfacejava.lang.AutoCloseable
- Throws:
java.lang.Exception
- If any of the containedAsyncCloseable
s terminate with a failure.
-
-