Pool for running {@link TimedCancelable}, time limited tasks.
Users are provided a {@link TaskHandle} for each task. The {@link TaskHandle}supports canceling the task and determining if the task is done running.
The ThreadPool enforces a configurable maximum time interval for tasks. Each task is guarded by a
time out task that will cancel the primary task if the primary task does not complete within the allowed interval.
If the configured maximum time interval is zero, tasks are allowed to run until explicitly cancelled, or shutdown.
Task cancellation includes two actions that are visible for the task task's {@link TimedCancelable}
- Calling {@link Future#cancel(boolean)} to send the task an interrupt andmark it as done.
- Calling {@link TimedCancelable#cancel()} to send the task a second signalthat it is being canceled. This signal has the benefit that it does not depend on the tasks interrupt handling policy.
Once a task has been canceled its {@link TaskHandle#isDone()} method willimmediately start returning {@code true}.
{@link ThreadPool} performs the following processing when a task completes
- Cancel the time out task for the completed task.
- Log exceptions that indicate the task did not complete normally.