Class FactoryPools

java.lang.Object
com.bumptech.glide.util.pool.FactoryPools

public final class FactoryPools extends Object
Provides implementations of Pools.Pool never return null, log when new instances are created, and that can use the FactoryPools.Poolable interface to ensure objects aren't used while inside the pool.
  • Method Details

    • simple

      @NonNull public static <T extends FactoryPools.Poolable> androidx.core.util.Pools.Pool<T> simple(int size, @NonNull FactoryPools.Factory<T> factory)
      Returns a non-thread safe Pools.Pool that never returns null from Pools.Pool.acquire() and that contains objects of the type created by the given FactoryPools.Factory with the given maximum size.

      If the pool is empty when Pools.Pool.acquire() is called, the given FactoryPools.Factory will be used to create a new instance.

      Type Parameters:
      T - The type of object the pool will contains.
    • threadSafe

      @NonNull public static <T extends FactoryPools.Poolable> androidx.core.util.Pools.Pool<T> threadSafe(int size, @NonNull FactoryPools.Factory<T> factory)
      Identical to threadSafe(int, Factory, Resetter) except no action is taken when an instance is returned to the pool.
    • threadSafe

      @NonNull public static <T extends FactoryPools.Poolable> androidx.core.util.Pools.Pool<T> threadSafe(int size, @NonNull FactoryPools.Factory<T> factory, @NonNull FactoryPools.Resetter<T> resetter)
      Returns a new thread safe Pools.Pool that never returns null from Pools.Pool.acquire() and that contains objects of the type created by the given FactoryPools.Factory with the given maximum size.

      If the pool is empty when Pools.Pool.acquire() is called, the given FactoryPools.Factory will be used to create a new instance.

      Each time an instance is returned to the pool resetter will be called with the given instance.

      Type Parameters:
      T - The type of object the pool will contains.
    • threadSafeList

      @NonNull public static <T> androidx.core.util.Pools.Pool<List<T>> threadSafeList()
      Returns a new Pools.Pool that never returns null and that contains Lists of a specific generic type with a standard maximum size of 20.

      If the pool is empty when Pools.Pool.acquire() is called, a new List will be created.

      Type Parameters:
      T - The type of object that the Lists will contain.
    • threadSafeList

      @NonNull public static <T> androidx.core.util.Pools.Pool<List<T>> threadSafeList(int size)
      Returns a new thread safe Pools.Pool that never returns null and that contains Lists of a specific generic type with the given maximum size.

      If the pool is empty when Pools.Pool.acquire() is called, a new List will be created.

      Type Parameters:
      T - The type of object that the Lists will contain.