Interface HelidonTaskExecutor

All Superinterfaces:
AutoCloseable, Closeable

public interface HelidonTaskExecutor extends Closeable
A simplified ExecutorService that can execute InterruptableTasks and can be efficiently terminated. A thread that is waiting to read on an open connection cannot be efficiently stopped. This executor will query the thread and interrupt it if possible. It is important to efficiently shut down the webserver in certain environments.
  • Method Summary

    Modifier and Type
    Method
    Description
    <T> Future<T>
    Executes a task.
    void
    Force termination by forcefully interrupting all tasks.
    boolean
    Verifies if the executor is terminated.
    boolean
    terminate(long timeout, TimeUnit unit)
    Terminate executor waiting for any running task to complete for a specified timeout period.

    Methods inherited from interface java.io.Closeable

    close
  • Method Details

    • execute

      <T> Future<T> execute(InterruptableTask<T> task)
      Executes a task.
      Type Parameters:
      T - type ov value returned by task
      Parameters:
      task - an interruptable task
      Returns:
      a future for a value returned by the task
    • isTerminated

      boolean isTerminated()
      Verifies if the executor is terminated.
      Returns:
      outcome of test
    • terminate

      boolean terminate(long timeout, TimeUnit unit)
      Terminate executor waiting for any running task to complete for a specified timeout period. It will only wait for those InterruptableTasks that are not interruptable.
      Parameters:
      timeout - timeout period
      unit - timeout period unit
      Returns:
      outcome of shutdown process
    • forceTerminate

      void forceTerminate()
      Force termination by forcefully interrupting all tasks. Shall only be called if terminate(long, java.util.concurrent.TimeUnit) returns false.