Package io.deephaven.util.process
Interface ShutdownManager
- All Known Implementing Classes:
ShutdownManagerImpl
public interface ShutdownManager
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumCategories that define ordering "groups" for serial execution during task invocation.static interfaceA single unit of work for shutdown. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a shutdown hook to the runtime that will invoke all registered shutdown tasks, if they haven't previously been invoked.voidWaits for the shutdown tasks to be finished (even if they have not been invoked yet).voidderegisterTask(@NotNull ShutdownManager.OrderingCategory orderingCategory, @NotNull ShutdownManager.Task task) Remove the most recent registration of task with orderingCategory.booleanInvoke all registered shutdown tasks, if they haven't previously been invoked.voidregisterTask(@NotNull ShutdownManager.OrderingCategory orderingCategory, @NotNull ShutdownManager.Task task) Register task for shutdown invocation along with other tasks belonging to orderingCategory.voidreset()Clear all shutdown tasks and reset internal state.boolean
-
Method Details
-
addShutdownHookToRuntime
void addShutdownHookToRuntime()Add a shutdown hook to the runtime that will invoke all registered shutdown tasks, if they haven't previously been invoked. If the tasks have already been invoked, e.g. by a direct invocation ofmaybeInvokeTasks(), the shutdown hook willawaitTasksFinished(). -
registerTask
void registerTask(@NotNull @NotNull ShutdownManager.OrderingCategory orderingCategory, @NotNull @NotNull ShutdownManager.Task task) Register task for shutdown invocation along with other tasks belonging to orderingCategory. Registration concurrent with invocation (that is, shutdown in progress) is not guaranteed to be effective.- Parameters:
orderingCategory-task-
-
deregisterTask
void deregisterTask(@NotNull @NotNull ShutdownManager.OrderingCategory orderingCategory, @NotNull @NotNull ShutdownManager.Task task) Remove the most recent registration of task with orderingCategory. De-registration concurrent with invocation (that is, shutdown in progress) is not guaranteed to be effective.- Parameters:
orderingCategory-task-
-
reset
void reset()Clear all shutdown tasks and reset internal state. Useful for unit tests, not safe for production use cases. -
tasksInvoked
boolean tasksInvoked()- Returns:
- True if shutdown tasks have been invoked (meaning shutdown is in progress).
-
maybeInvokeTasks
boolean maybeInvokeTasks()Invoke all registered shutdown tasks, if they haven't previously been invoked.- Returns:
- True if shutdown task invocation was performed by this call
-
awaitTasksFinished
Waits for the shutdown tasks to be finished (even if they have not been invoked yet). Does not invoke the shutdown tasks.- Throws:
InterruptedException- if the current thread is interrupted while waiting
-