Package io.deephaven.util.process
Class ShutdownManagerImpl
java.lang.Object
io.deephaven.util.process.ShutdownManagerImpl
- All Implemented Interfaces:
ShutdownManager
This is a helper class for keeping track of one-time shutdown tasks. Tasks are dispatched serially according to their
ordering category (first, middle, last), and in LIFO (last in, first out) order within their category.
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.deephaven.util.process.ShutdownManager
ShutdownManager.OrderingCategory, ShutdownManager.Task
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a shutdown hook to the runtime that will invoke all registered shutdown tasks, if they haven't previously been invoked.void
deregisterTask
(@NotNull ShutdownManager.OrderingCategory orderingCategory, @NotNull ShutdownManager.Task task) Remove the most recent registration of task with orderingCategory.static void
logShutdown
(LogLevel level, Object... items) Attempt to log a line of items.boolean
Invoke all registered shutdown tasks, if they haven't previously been invoked.void
registerTask
(@NotNull ShutdownManager.OrderingCategory orderingCategory, @NotNull ShutdownManager.Task task) Register task for shutdown invocation along with other tasks belonging to orderingCategory.void
reset()
Clear all shutdown tasks and reset internal state.boolean
-
Constructor Details
-
ShutdownManagerImpl
public ShutdownManagerImpl()Construct a new ShutdownManager.
-
-
Method Details
-
addShutdownHookToRuntime
public void addShutdownHookToRuntime()Description copied from interface:ShutdownManager
Add a shutdown hook to the runtime that will invoke all registered shutdown tasks, if they haven't previously been invoked.- Specified by:
addShutdownHookToRuntime
in interfaceShutdownManager
-
registerTask
public void registerTask(@NotNull @NotNull ShutdownManager.OrderingCategory orderingCategory, @NotNull @NotNull ShutdownManager.Task task) Description copied from interface:ShutdownManager
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.- Specified by:
registerTask
in interfaceShutdownManager
-
deregisterTask
public void deregisterTask(@NotNull @NotNull ShutdownManager.OrderingCategory orderingCategory, @NotNull @NotNull ShutdownManager.Task task) Description copied from interface:ShutdownManager
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.- Specified by:
deregisterTask
in interfaceShutdownManager
-
reset
public void reset()Description copied from interface:ShutdownManager
Clear all shutdown tasks and reset internal state. Useful for unit tests, not safe for production use cases.- Specified by:
reset
in interfaceShutdownManager
-
tasksInvoked
public boolean tasksInvoked()- Specified by:
tasksInvoked
in interfaceShutdownManager
- Returns:
- True if shutdown tasks have been invoked (meaning shutdown is in progress).
-
maybeInvokeTasks
public boolean maybeInvokeTasks()Description copied from interface:ShutdownManager
Invoke all registered shutdown tasks, if they haven't previously been invoked.- Specified by:
maybeInvokeTasks
in interfaceShutdownManager
- Returns:
- True if shutdown task invocation was performed by this call
-
logShutdown
Attempt to log a line of items. Fails silently if any Throwable is thrown, including Throwables one might ordinarily prefer not to catch (e.g. InterruptedException, subclasses of Error, etc). This is intended for use in processes that are shutting down.
-