Class ShutdownManagerImpl

java.lang.Object
io.deephaven.util.process.ShutdownManagerImpl
All Implemented Interfaces:
ShutdownManager

public class ShutdownManagerImpl extends Object implements 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.
  • 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 interface ShutdownManager
    • 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 interface ShutdownManager
    • 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 interface ShutdownManager
    • 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 interface ShutdownManager
    • tasksInvoked

      public boolean tasksInvoked()
      Specified by:
      tasksInvoked in interface ShutdownManager
      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 interface ShutdownManager
      Returns:
      True if shutdown task invocation was performed by this call
    • logShutdown

      public static void logShutdown(LogLevel level, Object... items)
      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.