com.bulletphysics.util
Class ObjectPool<T>

java.lang.Object
  extended by com.bulletphysics.util.ObjectPool<T>

public class ObjectPool<T>
extends Object

Object pool.


Constructor Summary
ObjectPool(Class<T> cls)
           
 
Method Summary
static void cleanCurrentThread()
           
 T get()
          Returns instance from pool, or create one if pool is empty.
static
<T> ObjectPool<T>
get(Class<T> cls)
          Returns per-thread object pool for given type, or create one if it doesn't exist.
 void release(T obj)
          Release instance into pool.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ObjectPool

public ObjectPool(Class<T> cls)
Method Detail

get

public T get()
Returns instance from pool, or create one if pool is empty.

Returns:
instance

release

public void release(T obj)
Release instance into pool.

Parameters:
obj - previously obtained instance from pool

get

public static <T> ObjectPool<T> get(Class<T> cls)
Returns per-thread object pool for given type, or create one if it doesn't exist.

Parameters:
cls - type
Returns:
object pool

cleanCurrentThread

public static void cleanCurrentThread()