public final class FactoryPools
extends java.lang.Object
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.Modifier and Type | Class and Description |
---|---|
static interface |
FactoryPools.Factory<T>
Creates new instances of the given type.
|
static interface |
FactoryPools.Poolable
Allows additional verification to catch errors caused by using objects while they are in
an object pool.
|
static interface |
FactoryPools.Resetter<T>
Resets state when objects are returned to the pool.
|
Modifier and Type | Method and Description |
---|---|
static <T extends FactoryPools.Poolable> |
simple(int size,
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. |
static <T extends FactoryPools.Poolable> |
threadSafe(int size,
FactoryPools.Factory<T> factory)
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. |
static <T> android.support.v4.util.Pools.Pool<java.util.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. |
static <T> android.support.v4.util.Pools.Pool<java.util.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. |
@NonNull public static <T extends FactoryPools.Poolable> android.support.v4.util.Pools.Pool<T> simple(int size, @NonNull FactoryPools.Factory<T> factory)
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.
T
- The type of object the pool will contains.@NonNull public static <T extends FactoryPools.Poolable> android.support.v4.util.Pools.Pool<T> threadSafe(int size, @NonNull FactoryPools.Factory<T> factory)
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.
T
- The type of object the pool will contains.@NonNull public static <T> android.support.v4.util.Pools.Pool<java.util.List<T>> threadSafeList()
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.
T
- The type of object that the Lists
will contain.@NonNull public static <T> android.support.v4.util.Pools.Pool<java.util.List<T>> threadSafeList(int size)
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.
T
- The type of object that the Lists
will contain.