Interface DwAsyncService

All Known Implementing Classes:
DwAsyncServiceImpl

public interface DwAsyncService
A service that allows to run asynchronous tasks. Via the service managed threadpools (see ExecutorService) can be created.
  • Method Details

    • poolExists

      boolean poolExists(String poolToken)
      Returns true if pool identified by poolToken exists
      Parameters:
      poolToken - The pool identifier
    • initPool

      DwAsyncPool initPool(String poolToken, PoolConfiguration configuration)
      Initializes a new pool for the given configuration. If a pool for poolToken already exists, the old pool is terminated.
      Parameters:
      poolToken -
      configuration -
      Returns:
      The pool
    • getPool

      DwAsyncPool getPool(String poolToken)
      Returns the pool identified by poolToken or null.
      Parameters:
      poolToken -
    • shutdownPool

      void shutdownPool(String poolToken)
      If pool exists, the pool is asked to orderly shutdown.
      Parameters:
      poolToken -
      See Also:
    • shutdownPoolNow

      List<Runnable> shutdownPoolNow(String poolToken)
      If pool exists, the pool is shutdown immediately.
      Parameters:
      poolToken -
      Returns:
      list of tasks that never commenced execution
      See Also:
    • awaitTerminationForPool

      boolean awaitTerminationForPool(String poolToken, long timeout, TimeUnit unit) throws InterruptedException
      Blocks until all tasks have completed execution after a shutdown request for the given pool
      Parameters:
      poolToken - The pool identifier
      timeout -
      unit -
      Throws:
      InterruptedException
      See Also:
    • isShutdownPool

      boolean isShutdownPool(String poolToken)
      Returns true if the pool was asked to shutdown.
      Parameters:
      poolToken -
      See Also:
    • isTerminatedPool

      boolean isTerminatedPool(String poolToken)
      Returns true if all tasks have completed following shut down.
      Parameters:
      poolToken -
    • getNrOfPools

      int getNrOfPools()
      Returns the number of pools
      Returns:
      the number of pools
    • getActiveCountAll

      int getActiveCountAll()
      Returns the approximately number of active threads in all pools.
      Returns:
      the number of threads
    • getTaskCountAll

      long getTaskCountAll()
      Returns the approximate total number of tasks that have ever been scheduled for execution summed over all pools.
      Returns:
      The number of tasks
    • getCompletedTaskCountAll

      long getCompletedTaskCountAll()
      Returns the approximate total number of tasks that have completed execution summed over all pools.
      Returns:
      the number of tasks
    • shutdownAll

      void shutdownAll()
      Calls shutdown on all pools.
      See Also:
    • shutdownAllNow

      List<Runnable> shutdownAllNow()
      Calls shutdownNow on all pools.
      See Also:
    • submit

      void submit(Runnable task)
      Submits a task to be run on the default thread pool
      Parameters:
      task -
    • suhtdownDefault

      void suhtdownDefault()
      Shuts down the default thread pool
    • shutdownNowDefault

      List<Runnable> shutdownNowDefault()
      Terminates the default thread pool.