Class AbstractShutdownableResource<R>

    • Constructor Detail

      • AbstractShutdownableResource

        protected AbstractShutdownableResource​(R object)
    • Method Detail

      • signalShutdownInitiated

        protected final void signalShutdownInitiated()
        Called by the Runnable to indicate that shutdown has started.
      • constructShutdown

        protected abstract java.lang.Runnable constructShutdown​(R object)
        The constructed runnable must call signalShutdownInitiated() method to indicate that shutdown has started.
        Parameters:
        object - Object to be shutdown
        Returns:
        Runnable instance
      • isShutdown

        public final boolean isShutdown()
        Returns true if this resource has been shut down.
        Specified by:
        isShutdown in interface ShutdownableResource
        Returns:
        true if this resource has been shut down
      • isTerminated

        public final boolean isTerminated()
        Returns true if the resource has completed shutting down. Note that isTerminated is never true unless shutdown was called first.
        Specified by:
        isTerminated in interface ShutdownableResource
        Returns:
        true if the resource has completed shutting down.
      • waitForShutdown

        public final void waitForShutdown()
                                   throws java.lang.InterruptedException,
                                          java.lang.IllegalStateException
        Waits for shutdown to complete
        Specified by:
        waitForShutdown in interface Shutdownable
        Throws:
        java.lang.InterruptedException - when the wait is interrupted
        java.lang.IllegalStateException - when the method is invoked when the shutdown has yet to start
      • waitForShutdown

        public final void waitForShutdown​(long timeoutInMs)
                                   throws java.lang.InterruptedException,
                                          java.lang.IllegalStateException,
                                          java.util.concurrent.TimeoutException
        Waits for shutdown to complete with a timeout
        Specified by:
        waitForShutdown in interface Shutdownable
        Parameters:
        timeoutInMs - number of milliseconds to wait before throwing TimeoutException
        Throws:
        java.lang.InterruptedException - when the wait is interrupted
        java.lang.IllegalStateException - when the method is invoked when the shutdown has yet to start
        java.util.concurrent.TimeoutException - when the operation times out
      • toString

        public final java.lang.String toString()
        Overrides:
        toString in class java.lang.Object