APIdia Launch Partner
Top Description Fields Constructors Methods
com.badlogic.gdx.utils

public Class PoolManager

extends Object
Class Inheritance
Annotations
@SuppressWarnings:unchecked
Imports
com.badlogic.gdx.utils.DefaultPool.PoolSupplier

A class that can be used to handle multiple pools together. Explicit pool registration is needed via PoolManager#addPool(Class, PoolSupplier)/PoolManager#addPool(Class, Pool).

Field Summary

Modifier and TypeField and Description
private final ObjectMap<Class<?>, Pool<?>>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public <T> void
addPool(Class<T> poolClass, DefaultPool.PoolSupplier<T> poolSupplier)

Registers a new pool with the given supplier.

public <T> void
addPool(Class<T> poolClass, Pool<T> pool)

Registers the new pool.

public void
clear()

Clears all contents of the managed pools

public <T> void
free(T object)

Frees a pooled object.

public <T> Pool<T>
getPool(Class<T> clazz)

Returns the pool registered for the class.

public <T> Pool<T>
getPoolOrNull(Class<T> clazz)

Returns the pool registered for the class.

public boolean
hasPool(Class<?> clazz)

Whether a pool for this class is already registered

public <T> T
obtain(Class<T> clazz)

Returns a new pooled object for the class.

public <T> T
obtainOrNull(Class<T> clazz)

Returns a new pooled object for the class.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

typePoolsback to summary
private final ObjectMap<Class<?>, Pool<?>> typePools

Constructor Detail

PoolManagerback to summary
public PoolManager()

Method Detail

addPoolback to summary
public <T> void addPool(Class<T> poolClass, DefaultPool.PoolSupplier<T> poolSupplier)

Registers a new pool with the given supplier. Will throw an exception, if a pool for the same class is already registered. This can be used like `PoolManager#addPoll(MyClass::new);`

addPoolback to summary
public <T> void addPool(Class<T> poolClass, Pool<T> pool)

Registers the new pool. Will throw an exception, if a pool for the same class is already registered

clearback to summary
public void clear()

Clears all contents of the managed pools

freeback to summary
public <T> void free(T object)

Frees a pooled object. Will throw an exception, if no pool for this class is registered. It is unchecked, whether the object was obtained by the registered pool.

getPoolback to summary
public <T> Pool<T> getPool(Class<T> clazz)

Returns the pool registered for the class. Will throw an exception, if no pool for this class is registered

getPoolOrNullback to summary
public <T> Pool<T> getPoolOrNull(Class<T> clazz)

Returns the pool registered for the class. Will return null, if no pool for this class is registered

hasPoolback to summary
public boolean hasPool(Class<?> clazz)

Whether a pool for this class is already registered

obtainback to summary
public <T> T obtain(Class<T> clazz)

Returns a new pooled object for the class. Will throw an exception, if no pool for this class is registered. Free with PoolManager#free

obtainOrNullback to summary
public <T> T obtainOrNull(Class<T> clazz)

Returns a new pooled object for the class. Will return null, if no pool for this class is registered. Free with PoolManager#free