Class Pools


  • public class Pools
    extends java.lang.Object
    Stores a map of Pools (usually ReflectionPools) by type for convenient static access.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void free​(java.lang.Object object)
      Frees an object from the pool.
      static void freeAll​(Array objects)
      Frees the specified objects from the pool.
      static void freeAll​(Array objects, boolean samePool)
      Frees the specified objects from the pool.
      static <T> Pool<T> get​(java.lang.Class<T> type)
      Returns a new or existing pool for the specified type, stored in a Class to Pool map.
      static <T> Pool<T> get​(java.lang.Class<T> type, int max)
      Returns a new or existing pool for the specified type, stored in a Class to Pool map.
      static <T> T obtain​(java.lang.Class<T> type)
      Obtains an object from the pool.
      static <T> void set​(java.lang.Class<T> type, Pool<T> pool)
      Sets an existing pool for the specified type, stored in a Class to Pool map.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • get

        public static <T> Pool<T> get​(java.lang.Class<T> type,
                                      int max)
        Returns a new or existing pool for the specified type, stored in a Class to Pool map. Note the max size is ignored if this is not the first time this pool has been requested.
      • get

        public static <T> Pool<T> get​(java.lang.Class<T> type)
        Returns a new or existing pool for the specified type, stored in a Class to Pool map. The max size of the pool used is 100.
      • set

        public static <T> void set​(java.lang.Class<T> type,
                                   Pool<T> pool)
        Sets an existing pool for the specified type, stored in a Class to Pool map.
      • obtain

        public static <T> T obtain​(java.lang.Class<T> type)
        Obtains an object from the pool.
      • free

        public static void free​(java.lang.Object object)
        Frees an object from the pool.
      • freeAll

        public static void freeAll​(Array objects)
        Frees the specified objects from the pool. Null objects within the array are silently ignored. Objects don't need to be from the same pool.
      • freeAll

        public static void freeAll​(Array objects,
                                   boolean samePool)
        Frees the specified objects from the pool. Null objects within the array are silently ignored.
        Parameters:
        samePool - If true, objects don't need to be from the same pool but the pool must be looked up for each object.