Package com.bumptech.glide.util.pool
Class FactoryPools
- java.lang.Object
-
- com.bumptech.glide.util.pool.FactoryPools
-
public final class FactoryPools extends java.lang.ObjectProvides implementations ofPools.Poolnever returnnull, log when new instances are created, and that can use theFactoryPools.Poolableinterface to ensure objects aren't used while inside the pool.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceFactoryPools.Factory<T>Creates new instances of the given type.static interfaceFactoryPools.PoolableAllows additional verification to catch errors caused by using objects while they are in an object pool.static interfaceFactoryPools.Resetter<T>Resets state when objects are returned to the pool.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T extends FactoryPools.Poolable>
androidx.core.util.Pools.Pool<T>simple(int size, FactoryPools.Factory<T> factory)Returns a non-thread safePools.Poolthat never returnsnullfromPools.Pool.acquire()and that contains objects of the type created by the givenFactoryPools.Factorywith the given maximum size.static <T extends FactoryPools.Poolable>
androidx.core.util.Pools.Pool<T>threadSafe(int size, FactoryPools.Factory<T> factory)Returns a new thread safePools.Poolthat never returnsnullfromPools.Pool.acquire()and that contains objects of the type created by the givenFactoryPools.Factorywith the given maximum size.static <T> androidx.core.util.Pools.Pool<java.util.List<T>>threadSafeList()Returns a newPools.Poolthat never returnsnulland that containsListsof a specific generic type with a standard maximum size of 20.static <T> androidx.core.util.Pools.Pool<java.util.List<T>>threadSafeList(int size)Returns a new thread safePools.Poolthat never returnsnulland that containsListsof a specific generic type with the given maximum size.
-
-
-
Method Detail
-
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 safePools.Poolthat never returnsnullfromPools.Pool.acquire()and that contains objects of the type created by the givenFactoryPools.Factorywith the given maximum size.If the pool is empty when
Pools.Pool.acquire()is called, the givenFactoryPools.Factorywill 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)
Returns a new thread safePools.Poolthat never returnsnullfromPools.Pool.acquire()and that contains objects of the type created by the givenFactoryPools.Factorywith the given maximum size.If the pool is empty when
Pools.Pool.acquire()is called, the givenFactoryPools.Factorywill be used to create a new instance.- Type Parameters:
T- The type of object the pool will contains.
-
threadSafeList
@NonNull public static <T> androidx.core.util.Pools.Pool<java.util.List<T>> threadSafeList()
Returns a newPools.Poolthat never returnsnulland that containsListsof a specific generic type with a standard maximum size of 20.If the pool is empty when
Pools.Pool.acquire()is called, a newListwill be created.- Type Parameters:
T- The type of object that theListswill contain.
-
threadSafeList
@NonNull public static <T> androidx.core.util.Pools.Pool<java.util.List<T>> threadSafeList(int size)
Returns a new thread safePools.Poolthat never returnsnulland that containsListsof a specific generic type with the given maximum size.If the pool is empty when
Pools.Pool.acquire()is called, a newListwill be created.- Type Parameters:
T- The type of object that theListswill contain.
-
-