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 passedAsyncCloseablewith thisCompositeCloseablesuch that when thisCompositeCloseableis closed, all of the previously registeredAsyncCloseables are closed too.CompositeCloseableappendAll(AsyncCloseable... asyncCloseables)Appends all the passedAsyncCloseables with thisCompositeCloseablesuch that when thisCompositeCloseableis closed, all of theseAsyncCloseables are closed too.CompositeCloseableappendAll(java.lang.Iterable<? extends AsyncCloseable> asyncCloseables)Appends all the passedAsyncCloseables with thisCompositeCloseablesuch that when thisCompositeCloseableis closed, all of theseAsyncCloseables are closed too.voidclose()Closes all containedAsyncCloseables and awaits termination of all of them.CompletablecloseAsync()Closes all containedAsyncCloseables.<T extends AsyncCloseable>
Tmerge(T closeable)Merges the passedAsyncCloseablewith thisCompositeCloseablesuch that when thisCompositeCloseableis closed, all of the previously registeredAsyncCloseables are closed too.CompositeCloseablemergeAll(AsyncCloseable... asyncCloseables)Merges all the passedAsyncCloseables with thisCompositeCloseablesuch that when thisCompositeCloseableis closed, all of theseAsyncCloseables are closed too.CompositeCloseablemergeAll(java.lang.Iterable<? extends AsyncCloseable> asyncCloseables)Merges all the passedAsyncCloseables with thisCompositeCloseablesuch that when thisCompositeCloseableis closed, all of theseAsyncCloseables are closed too.<T extends AsyncCloseable>
Tprepend(T closeable)Prepends the passedAsyncCloseablewith thisCompositeCloseablesuch that when thisCompositeCloseableis closed, all of the previously registeredAsyncCloseables are closed too.CompositeCloseableprependAll(AsyncCloseable... asyncCloseables)Prepends all the passedAsyncCloseables with thisCompositeCloseablesuch that when thisCompositeCloseableis closed, all of theseAsyncCloseables are closed too.CompositeCloseableprependAll(java.lang.Iterable<? extends AsyncCloseable> asyncCloseables)Prepends all the passedAsyncCloseables with thisCompositeCloseablesuch that when thisCompositeCloseableis closed, all of theseAsyncCloseables 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 passedAsyncCloseablewith thisCompositeCloseablesuch that when thisCompositeCloseableis closed, all of the previously registeredAsyncCloseables are closed too. This method subscribes to the passed inAsyncCloseableand 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 ofAsyncCloseableto be merged- Parameters:
closeable-AsyncCloseablethat is closed when thisCompositeCloseableis closed.- Returns:
T
-
mergeAll
CompositeCloseable mergeAll(AsyncCloseable... asyncCloseables)
Merges all the passedAsyncCloseables with thisCompositeCloseablesuch that when thisCompositeCloseableis closed, all of theseAsyncCloseables are closed too. This method subscribes to all passed inAsyncCloseables and the current composite set at the same time. If an order of closure is required, then useappendAll(AsyncCloseable...)orprependAll(AsyncCloseable...).- Parameters:
asyncCloseables- AllAsyncCloseables that are closed when thisCompositeCloseableis closed.- Returns:
this.
-
mergeAll
CompositeCloseable mergeAll(java.lang.Iterable<? extends AsyncCloseable> asyncCloseables)
Merges all the passedAsyncCloseables with thisCompositeCloseablesuch that when thisCompositeCloseableis closed, all of theseAsyncCloseables are closed too. This method subscribes to all passed inAsyncCloseables and the current composite set at the same time. If an order of closure is required, then useappendAll(AsyncCloseable...)orprependAll(AsyncCloseable...).- Parameters:
asyncCloseables- AllAsyncCloseables that are closed when thisCompositeCloseableis closed.- Returns:
this.
-
append
<T extends AsyncCloseable> T append(T closeable)
Appends the passedAsyncCloseablewith thisCompositeCloseablesuch that when thisCompositeCloseableis closed, all of the previously registeredAsyncCloseables are closed too. This method subscribes to the passed inAsyncCloseableand the current composite set in order. If an order of closure is not required, then usemerge(AsyncCloseable).- Type Parameters:
T- the type ofAsyncCloseableto be appended- Parameters:
closeable-AsyncCloseablethat is closed when thisCompositeCloseableis closed.- Returns:
T.
-
appendAll
CompositeCloseable appendAll(AsyncCloseable... asyncCloseables)
Appends all the passedAsyncCloseables with thisCompositeCloseablesuch that when thisCompositeCloseableis closed, all of theseAsyncCloseables are closed too. This method subscribes to all passed inAsyncCloseables 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- AllAsyncCloseables that are closed when thisCompositeCloseableis closed.- Returns:
this.
-
appendAll
CompositeCloseable appendAll(java.lang.Iterable<? extends AsyncCloseable> asyncCloseables)
Appends all the passedAsyncCloseables with thisCompositeCloseablesuch that when thisCompositeCloseableis closed, all of theseAsyncCloseables are closed too. This method subscribes to all passed inAsyncCloseables 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- AllAsyncCloseables that are closed when thisCompositeCloseableis closed.- Returns:
this.
-
prepend
<T extends AsyncCloseable> T prepend(T closeable)
Prepends the passedAsyncCloseablewith thisCompositeCloseablesuch that when thisCompositeCloseableis closed, all of the previously registeredAsyncCloseables are closed too. This method subscribes to the passed inAsyncCloseableand the current composite set in reverse order. If an order of closure is not required, then usemerge(AsyncCloseable).- Type Parameters:
T- the type ofAsyncCloseableto be prepended- Parameters:
closeable-AsyncCloseablethat is closed when thisCompositeCloseableis closed.- Returns:
T.
-
prependAll
CompositeCloseable prependAll(AsyncCloseable... asyncCloseables)
Prepends all the passedAsyncCloseables with thisCompositeCloseablesuch that when thisCompositeCloseableis closed, all of theseAsyncCloseables are closed too. This method subscribes to all passed inAsyncCloseables 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- AllAsyncCloseables that are closed when thisCompositeCloseableis closed.- Returns:
this.
-
prependAll
CompositeCloseable prependAll(java.lang.Iterable<? extends AsyncCloseable> asyncCloseables)
Prepends all the passedAsyncCloseables with thisCompositeCloseablesuch that when thisCompositeCloseableis closed, all of theseAsyncCloseables are closed too. This method subscribes to all passed inAsyncCloseables 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- AllAsyncCloseables that are closed when thisCompositeCloseableis closed.- Returns:
this.
-
closeAsync
Completable closeAsync()
Closes all containedAsyncCloseables. If any of the containedAsyncCloseables terminated with a failure, the returnedCompletableterminates with a failure only after all the containedAsyncCloseables have terminated.- Specified by:
closeAsyncin interfaceAsyncCloseable- Returns:
- the
Completablethat is notified once the close is complete.
-
close
void close() throws java.lang.ExceptionCloses all containedAsyncCloseables and awaits termination of all of them. If any of the containedAsyncCloseables terminated with a failure, this method terminates with anExceptiononly after all the containedAsyncCloseables have terminated.- Specified by:
closein interfacejava.lang.AutoCloseable- Throws:
java.lang.Exception- If any of the containedAsyncCloseables terminate with a failure.
-
-