Package io.servicetalk.concurrent.api
Class AutoCloseables
java.lang.Object
io.servicetalk.concurrent.api.AutoCloseables
A utility class for methods related to
AutoCloseable
.-
Method Summary
Modifier and TypeMethodDescriptionstatic void
closeGracefully
(Executor executor, GracefulAutoCloseable closable, long gracefulCloseTimeout, TimeUnit gracefulCloseTimeoutUnit) InvokesGracefulAutoCloseable.closeGracefully()
on theclosable
, applies a timeout, and if the timeout fires forces a call toAutoCloseable.close()
.
-
Method Details
-
closeGracefully
public static void closeGracefully(Executor executor, GracefulAutoCloseable closable, long gracefulCloseTimeout, TimeUnit gracefulCloseTimeoutUnit) throws Exception InvokesGracefulAutoCloseable.closeGracefully()
on theclosable
, applies a timeout, and if the timeout fires forces a call toAutoCloseable.close()
.- Parameters:
executor
-Executor
to use for applying timeout.closable
- TheGracefulAutoCloseable
to initiateGracefulAutoCloseable.closeGracefully()
on.gracefulCloseTimeout
- The timeout duration to wait forGracefulAutoCloseable.closeGracefully()
to complete.gracefulCloseTimeoutUnit
- The time unit applied togracefulCloseTimeout
.- Throws:
Exception
- if graceful closure failed.
-