Class BoundedExecutorServiceWrapper

java.lang.Object
com.atlassian.jira.util.BoundedExecutorServiceWrapper
All Implemented Interfaces:
ExecutorServiceWrapper

public final class BoundedExecutorServiceWrapper extends Object implements ExecutorServiceWrapper
Wraps an ExecutorService to ensure the number of queued tasks is bounded to the specified concurrency. Submission of tasks will block until a thread is available.

Construct using a BoundedExecutorServiceWrapper.Builder.

Since:
v6.3
  • Method Details

    • submit

      public <O> io.atlassian.util.concurrent.Promise<O> submit(Callable<O> job)
      Specified by:
      submit in interface ExecutorServiceWrapper
    • awaitTermination

      public boolean awaitTermination()
      Shutdown thread pool and block until it is drained using the configured timeout.
      Specified by:
      awaitTermination in interface ExecutorServiceWrapper
      Returns:
      true if the executor service has been shutdown.
    • awaitTermination

      public boolean awaitTermination(long timeout, TimeUnit unit)
      Shutdown thread pool and block until it is drained.
      Specified by:
      awaitTermination in interface ExecutorServiceWrapper
      Parameters:
      timeout - the shutdown timeout
      unit - the shutdown timeout unit
      Returns:
      true if the executor service has been shutdown.
    • isTerminated

      public boolean isTerminated()
      Specified by:
      isTerminated in interface ExecutorServiceWrapper