Class SimplePool

java.lang.Object
org.apache.velocity.util.SimplePool

public final class SimplePool extends Object
Simple object pool. Based on ThreadPool and few other classes The pool will ignore overflow and return null if empty.
Version:
$Id: SimplePool.java 463298 2006-10-12 16:10:32Z henning $
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private int
    index of previous to next free slot
    private int
    max amount of objects to be managed set via CTOR
    private Object[]
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    SimplePool(int max)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    get()
    Get an object from the pool, null if the pool is empty.
    int
    Return the size of the pool
    (package private) Object[]
    for testing purposes, so we can examine the pool
    void
    Add the object to the pool, silent nothing if the pool is full

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • pool

      private Object[] pool
    • max

      private int max
      max amount of objects to be managed set via CTOR
    • current

      private int current
      index of previous to next free slot
  • Constructor Details

    • SimplePool

      public SimplePool(int max)
      Parameters:
      max -
  • Method Details

    • put

      public void put(Object o)
      Add the object to the pool, silent nothing if the pool is full
      Parameters:
      o -
    • get

      public Object get()
      Get an object from the pool, null if the pool is empty.
      Returns:
      The object from the pool.
    • getMax

      public int getMax()
      Return the size of the pool
      Returns:
      The pool size.
    • getPool

      Object[] getPool()
      for testing purposes, so we can examine the pool
      Returns:
      Array of Objects in the pool.