Class ServerCleaner

  • All Implemented Interfaces:
    java.lang.Runnable

    class ServerCleaner
    extends Daemon
    The ServerCleaner object allows for the termination and resource recovery to be done asynchronously. This ensures that should a HTTP request be used to terminate the processor that it does not block waiting for the servicing thread pool to terminate causing a deadlock.
    • Field Detail

      • processor

        private final TransportProcessor processor
        This is the internal processor that is to be terminated.
      • executor

        private final ConcurrentExecutor executor
        This is the thread pool implementation used by the server.
      • reactor

        private final Reactor reactor
        This is the internal write reactor that is terminated.
    • Constructor Detail

      • ServerCleaner

        public ServerCleaner​(TransportProcessor processor,
                             ConcurrentExecutor executor,
                             Reactor reactor)
        Constructor for the ServerCleaner object. For an orderly termination of the processor, the processor and reactor provided to the constructor will be stopped asynchronously.
        Parameters:
        processor - this is the processor that is to be stopped
        executor - this is the executor used by the server
        reactor - this is the reactor that is to be closed
    • Method Detail

      • run

        public void run()
        When this method runs it will firstly stop the processor in a synchronous fashion. Once the TransportProcessor has stopped it will stop the Reactor ensuring that all threads will be released.

        It is important to note that stopping the processor before stopping the reactor is required. This ensures that if there are any threads executing within the processor that require the reactor threads, they can complete without a problem.