pool
inline fun <Type> pool(initialCapacity: Int = 16, max: Int = Int.MAX_VALUE, crossinline discard: (Type) -> Unit = {
if (it is Poolable) {
it.reset()
}
}, crossinline provider: () -> Type): Pool<Type>
Return
a new Pool instance, creating the object with the passed provider.
Parameters
initialCapacity
initial size of the backing collection.
max
max amount stored in the pool. When exceeded, freed objects are no longer accepted.
discard
invoked each time an object is rejected or removed from the pool. This might happen if an object is freed with Pool.free or Pool.freeAll if the pool is full, or when Pool.clear is called. Optional, defaults to resetting the objects implementing the Poolable interface to replicate the default behavior. If the objects are Disposable, this lambda should be used to dispose of them.
provider
creates instances of the requested objects.