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
Constructors -
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.voidderegisterTask(@NotNull ShutdownManager.OrderingCategory orderingCategory, @NotNull ShutdownManager.Task task) Remove the most recent registration of task with orderingCategory.static voidlogShutdown(LogLevel level, Object... items) Attempt to log a line of items.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
-
Constructor Details
-
ShutdownManagerImpl
public ShutdownManagerImpl()Construct a new ShutdownManager.
-
-
Method Details
-
addShutdownHookToRuntime
public void addShutdownHookToRuntime()Description copied from interface:ShutdownManagerAdd a shutdown hook to the runtime that will invoke all registered shutdown tasks, if they haven't previously been invoked.- Specified by:
addShutdownHookToRuntimein interfaceShutdownManager
-
registerTask
public void registerTask(@NotNull @NotNull ShutdownManager.OrderingCategory orderingCategory, @NotNull @NotNull ShutdownManager.Task task) Description copied from interface:ShutdownManagerRegister 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:
registerTaskin interfaceShutdownManager
-
deregisterTask
public void deregisterTask(@NotNull @NotNull ShutdownManager.OrderingCategory orderingCategory, @NotNull @NotNull ShutdownManager.Task task) Description copied from interface:ShutdownManagerRemove 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:
deregisterTaskin interfaceShutdownManager
-
reset
public void reset()Description copied from interface:ShutdownManagerClear all shutdown tasks and reset internal state. Useful for unit tests, not safe for production use cases.- Specified by:
resetin interfaceShutdownManager
-
tasksInvoked
public boolean tasksInvoked()- Specified by:
tasksInvokedin interfaceShutdownManager- Returns:
- True if shutdown tasks have been invoked (meaning shutdown is in progress).
-
maybeInvokeTasks
public boolean maybeInvokeTasks()Description copied from interface:ShutdownManagerInvoke all registered shutdown tasks, if they haven't previously been invoked.- Specified by:
maybeInvokeTasksin 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.
-