Class CloseableTaskPoolSubmitter

java.lang.Object
org.apache.hadoop.util.functional.CloseableTaskPoolSubmitter
All Implemented Interfaces:
Closeable, AutoCloseable, org.apache.hadoop.util.functional.TaskPool.Submitter

@Public @Unstable public class CloseableTaskPoolSubmitter extends Object implements org.apache.hadoop.util.functional.TaskPool.Submitter, Closeable
A task submitter which is closeable, and whose close() call shuts down the pool. This can help manage thread pool lifecycles.
  • Constructor Details

    • CloseableTaskPoolSubmitter

      public CloseableTaskPoolSubmitter(ExecutorService pool)
      Constructor.
      Parameters:
      pool - non-null executor.
  • Method Details

    • getPool

      public ExecutorService getPool()
      Get the pool.
      Returns:
      the pool.
    • close

      public void close()
      Shut down the pool.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
    • submit

      public Future<?> submit(Runnable task)
      Description copied from interface: org.apache.hadoop.util.functional.TaskPool.Submitter
      Submit work.
      Specified by:
      submit in interface org.apache.hadoop.util.functional.TaskPool.Submitter
      Parameters:
      task - task to execute
      Returns:
      the future of the submitted task.