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.
  • 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