Class Pools

java.lang.Object
arc.util.pooling.Pools

public class Pools extends Object
Stores a map of Pools by type for convenient static access.
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    free(Object object)
    Frees an object from the pool.
    static void
    freeAll(Seq objects)
    Frees the specified objects from the pool.
    static void
    freeAll(Seq objects, boolean samePool)
    Frees the specified objects from the pool.
    static <T> Pool<T>
    get(Class<T> type, Prov<T> supplier)
    Returns a new or existing pool for the specified type, stored in a Class to Pool map.
    static <T> Pool<T>
    get(Class<T> type, Prov<T> supplier, int max)
    Returns a new or existing pool for the specified type, stored in a Class to Pool map.
    static <T> T
    obtain(Class<T> type, Prov<T> supplier)
    Obtains an object from the pool.
    static <T> void
    set(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 Details

    • get

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

      public static <T> Pool<T> get(Class<T> type, Prov<T> supplier)
      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 5000.
    • set

      public static <T> void set(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(Class<T> type, Prov<T> supplier)
      Obtains an object from the pool.
    • free

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

      public static void freeAll(Seq 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(Seq 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.