Package com.bumptech.glide.util.pool
Class FactoryPools
java.lang.Object
com.bumptech.glide.util.pool.FactoryPools
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.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceCreates new instances of the given type.static interfaceAllows additional verification to catch errors caused by using objects while they are in an object pool.static interfaceResets state when objects are returned to the pool. -
Method Summary
Modifier and TypeMethodDescriptionstatic <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) Identical tothreadSafe(int, Factory, Resetter)except no action is taken when an instance is returned to the pool.static <T extends FactoryPools.Poolable>
androidx.core.util.Pools.Pool<T>threadSafe(int size, FactoryPools.Factory<T> factory, FactoryPools.Resetter<T> resetter) 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<List<T>>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<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 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 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) Identical tothreadSafe(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 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.Each time an instance is returned to the pool
resetterwill be called with the given instance.- Type Parameters:
T- The type of object the pool will contains.
-
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
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.
-