RxTaskPool (Apache Tomcat 11.0.24 API Documentation)
Description: declaration: package: org.apache.catalina.tribes.transport, class: RxTaskPool

# Class RxTaskPool

java.lang.Object
org.apache.catalina.tribes.transport.RxTaskPool

public class RxTaskPool extends Object
A very simple thread pool class. The pool size is set at construction time and remains fixed. Threads are cycled through a FIFO idle queue.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static interface`
  `RxTaskPool.TaskCreator`
  Factory interface for creating receive tasks.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `RxTaskPool(int maxTasks, int minTasks, RxTaskPool.TaskCreator creator)`
  Create a new fixed-size receive task pool.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `int`
  `available()`
  Return the number of idle tasks currently available in the pool.
  `protected void`
  `configureTask(AbstractRxTask task)`
  Configure a receive task by associating it with this pool.
  `int`
  `getMaxThreads()`
  Return the maximum number of tasks allowed in the pool.
  `int`
  `getMinThreads()`
  Return the minimum number of tasks maintained in the pool.
  `AbstractRxTask`
  `getRxTask()`
  Find an idle worker thread, if any.
  `RxTaskPool.TaskCreator`
  `getTaskCreator()`
  Return the task creator factory used by this pool.
  `void`
  `returnWorker(AbstractRxTask worker)`
  Called by the worker thread to return itself to the idle pool.
  `void`
  `setMaxTasks(int maxThreads)`
  Set the maximum number of tasks allowed in the pool.
  `void`
  `setMinTasks(int minThreads)`
  Set the minimum number of tasks maintained in the pool.
  `void`
  `stop()`
  Stop the pool, closing all idle tasks and preventing new tasks from being acquired.

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### RxTaskPool

    public RxTaskPool(int maxTasks, int minTasks, RxTaskPool.TaskCreator creator) throws Exception
    Create a new fixed-size receive task pool.
    Parameters:
      `maxTasks` - maximum number of tasks in the pool
      `minTasks` - minimum number of tasks in the pool
      `creator` - factory for creating new receive tasks
    Throws:
      `Exception` - if initialization fails

- ## Method Details

  - ### configureTask

    protected void configureTask(AbstractRxTask task)
    Configure a receive task by associating it with this pool.
    Parameters:
      `task` - the task to configure

  - ### getRxTask

    public AbstractRxTask getRxTask()
    Find an idle worker thread, if any. Could return null.
    Returns:
      a worker

  - ### available

    public int available()
    Return the number of idle tasks currently available in the pool.
    Returns:
      count of idle tasks

  - ### returnWorker

    public void returnWorker(AbstractRxTask worker)
    Called by the worker thread to return itself to the idle pool.
    Parameters:
      `worker` - The worker

  - ### getMaxThreads

    public int getMaxThreads()
    Return the maximum number of tasks allowed in the pool.
    Returns:
      maximum task count

  - ### getMinThreads

    public int getMinThreads()
    Return the minimum number of tasks maintained in the pool.
    Returns:
      minimum task count

  - ### stop

    public void stop()
    Stop the pool, closing all idle tasks and preventing new tasks from being acquired.

  - ### setMaxTasks

    public void setMaxTasks(int maxThreads)
    Set the maximum number of tasks allowed in the pool.
    Parameters:
      `maxThreads` - maximum task count

  - ### setMinTasks

    public void setMinTasks(int minThreads)
    Set the minimum number of tasks maintained in the pool.
    Parameters:
      `minThreads` - minimum task count

  - ### getTaskCreator

    public RxTaskPool.TaskCreator getTaskCreator()
    Return the task creator factory used by this pool.
    Returns:
      the task creator